Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. GridView Problem..

GridView Problem..

Scheduled Pinned Locked Moved ASP.NET
databasehelpannouncement
13 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D DKalepu

    Hi Everyone, I have 4 columns GridView.. One is BoundField This column is binded to Sno field from my Access Datasource.. 2nd, 3rd & 4th columns are TemplateFields (PartNo, Manufacturer, Qunatity) .. In this Template Fields, I have textboxes./. Now, Below this Gridview i hv a Button (btnSubmit). What I am trying to do is when user enters values in to textboxes & click on Submit button, all the values should get update in the database.. To achieve this, i have written the following code: _______________________

    P Offline
    P Offline
    Pallavi Bhoite
    wrote on last edited by
    #2

    Hi DKalepu, I think , string str = ((TextBox)dgRow.FindControl("txtPartNo")).Text.ToString(); this line your code giving you problem as you finding control but grid view is having rows of controls so it take last value and gives u .. try to get values for perticular row . try this , myGridView1.Rows[dgRow.RowIndex].FindControl("txtPartNo")).Text.ToString(); i am not sure ..try some R&D on this u will find answer

    pallavi

    D 1 Reply Last reply
    0
    • D DKalepu

      Hi Everyone, I have 4 columns GridView.. One is BoundField This column is binded to Sno field from my Access Datasource.. 2nd, 3rd & 4th columns are TemplateFields (PartNo, Manufacturer, Qunatity) .. In this Template Fields, I have textboxes./. Now, Below this Gridview i hv a Button (btnSubmit). What I am trying to do is when user enters values in to textboxes & click on Submit button, all the values should get update in the database.. To achieve this, i have written the following code: _______________________

      B Offline
      B Offline
      ballameharmurali
      wrote on last edited by
      #3

      hello sir, Instead of keeping in ItemTemplate keep in EditItemTemplate.. ok It will work and plz check datasourceID and dataconnection ..I think only one should be declared. Try like this .. ok byee Murali Murali

      D 1 Reply Last reply
      0
      • P Pallavi Bhoite

        Hi DKalepu, I think , string str = ((TextBox)dgRow.FindControl("txtPartNo")).Text.ToString(); this line your code giving you problem as you finding control but grid view is having rows of controls so it take last value and gives u .. try to get values for perticular row . try this , myGridView1.Rows[dgRow.RowIndex].FindControl("txtPartNo")).Text.ToString(); i am not sure ..try some R&D on this u will find answer

        pallavi

        D Offline
        D Offline
        DKalepu
        wrote on last edited by
        #4

        Hi Pallavi, thanks for reply.... I have tried it by debugging. oh but still, same problem.. the value gets stored in the last row position only...:rolleyes: can u plz give me any other advices..... Thanks, Durga.

        1 Reply Last reply
        0
        • B ballameharmurali

          hello sir, Instead of keeping in ItemTemplate keep in EditItemTemplate.. ok It will work and plz check datasourceID and dataconnection ..I think only one should be declared. Try like this .. ok byee Murali Murali

          D Offline
          D Offline
          DKalepu
          wrote on last edited by
          #5

          Hi Murali, i hv tried using EditItemTemplate as u said... but itisn't showing any textboxes there...:confused: fyi, i'm a girl..:laugh::laugh: Thanks, Durga.

          B 1 Reply Last reply
          0
          • D DKalepu

            Hi Everyone, I have 4 columns GridView.. One is BoundField This column is binded to Sno field from my Access Datasource.. 2nd, 3rd & 4th columns are TemplateFields (PartNo, Manufacturer, Qunatity) .. In this Template Fields, I have textboxes./. Now, Below this Gridview i hv a Button (btnSubmit). What I am trying to do is when user enters values in to textboxes & click on Submit button, all the values should get update in the database.. To achieve this, i have written the following code: _______________________

            P Offline
            P Offline
            Pallavi Bhoite
            wrote on last edited by
            #6

            hi durga, put OleDbCommand cmd = new OleDbCommand(strQuery, myConnection); cmd.ExecuteNonQuery(); code in foreach loop .. now u will get what u want and put where cluase in your query :-D

            pallavi

            D 1 Reply Last reply
            0
            • D DKalepu

              Hi Murali, i hv tried using EditItemTemplate as u said... but itisn't showing any textboxes there...:confused: fyi, i'm a girl..:laugh::laugh: Thanks, Durga.

              B Offline
              B Offline
              ballameharmurali
              wrote on last edited by
              #7

              hello durga, in the edit item template u need to declare the asp:textbox it will not come automatically.try u will get... ok byeee Murali

              D 1 Reply Last reply
              0
              • D DKalepu

                Hi Everyone, I have 4 columns GridView.. One is BoundField This column is binded to Sno field from my Access Datasource.. 2nd, 3rd & 4th columns are TemplateFields (PartNo, Manufacturer, Qunatity) .. In this Template Fields, I have textboxes./. Now, Below this Gridview i hv a Button (btnSubmit). What I am trying to do is when user enters values in to textboxes & click on Submit button, all the values should get update in the database.. To achieve this, i have written the following code: _______________________

                H Offline
                H Offline
                Hirdesh Shrivastava
                wrote on last edited by
                #8

                Hi in your code errore is in the this line "strQuery = "UPDATE [RfqInfo] SET [Partno]= '" + str + "', [mfg] = '" + str1 + "', [qty] = '" + str2 + "'"; " you have not mantioned any whare condition for updating particuler row thats why when last time ur query get executed it update all rows by last row in ur gridview . Hirdesh

                D 1 Reply Last reply
                0
                • H Hirdesh Shrivastava

                  Hi in your code errore is in the this line "strQuery = "UPDATE [RfqInfo] SET [Partno]= '" + str + "', [mfg] = '" + str1 + "', [qty] = '" + str2 + "'"; " you have not mantioned any whare condition for updating particuler row thats why when last time ur query get executed it update all rows by last row in ur gridview . Hirdesh

                  D Offline
                  D Offline
                  DKalepu
                  wrote on last edited by
                  #9

                  Hi Hirdesh, thanks for replying... I have included the where condition but its showing.. "Syntax error (missing operator) in query expression '[Sno] = Sno[1]'." here is code snippet: int i = dgRow.RowIndex + 1; str = ((TextBox)myGridView1.Rows[dgRow.RowIndex].FindControl("txtPartNo")).Text.ToString(); strQuery = "UPDATE [RfqInfo] SET [Partno]= '" + str + "', [mfg] = '" + str1 + "', [qty] = '" + str2 + "' WHERE [Sno] = Sno[" + i + "]"; plz help me...

                  H 1 Reply Last reply
                  0
                  • B ballameharmurali

                    hello durga, in the edit item template u need to declare the asp:textbox it will not come automatically.try u will get... ok byeee Murali

                    D Offline
                    D Offline
                    DKalepu
                    wrote on last edited by
                    #10

                    I have tried it already, but it doesn't show up anything.....:confused:

                    1 Reply Last reply
                    0
                    • D DKalepu

                      Hi Hirdesh, thanks for replying... I have included the where condition but its showing.. "Syntax error (missing operator) in query expression '[Sno] = Sno[1]'." here is code snippet: int i = dgRow.RowIndex + 1; str = ((TextBox)myGridView1.Rows[dgRow.RowIndex].FindControl("txtPartNo")).Text.ToString(); strQuery = "UPDATE [RfqInfo] SET [Partno]= '" + str + "', [mfg] = '" + str1 + "', [qty] = '" + str2 + "' WHERE [Sno] = Sno[" + i + "]"; plz help me...

                      H Offline
                      H Offline
                      Hirdesh Shrivastava
                      wrote on last edited by
                      #11

                      replace your query string by strQuery = "UPDATE [RfqInfo] SET [Partno]= '" + str + "', [mfg] = '" + str1 + "', [qty] = '" + str2 + "' WHERE [Sno] = " + i; i'm sure ur code will run fine. Hirdesh :)

                      D 1 Reply Last reply
                      0
                      • H Hirdesh Shrivastava

                        replace your query string by strQuery = "UPDATE [RfqInfo] SET [Partno]= '" + str + "', [mfg] = '" + str1 + "', [qty] = '" + str2 + "' WHERE [Sno] = " + i; i'm sure ur code will run fine. Hirdesh :)

                        D Offline
                        D Offline
                        DKalepu
                        wrote on last edited by
                        #12

                        Hi, yup.. it worked very well now...Thank youveryyy much, once again thanks a lot..:-D

                        1 Reply Last reply
                        0
                        • P Pallavi Bhoite

                          hi durga, put OleDbCommand cmd = new OleDbCommand(strQuery, myConnection); cmd.ExecuteNonQuery(); code in foreach loop .. now u will get what u want and put where cluase in your query :-D

                          pallavi

                          D Offline
                          D Offline
                          DKalepu
                          wrote on last edited by
                          #13

                          Thanks for the kind help Pallavi.. My problem solved now..:-D

                          1 Reply Last reply
                          0
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • World
                          • Users
                          • Groups