GridView Problem..
-
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: _______________________
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
-
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
-
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
-
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: _______________________
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
-
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.
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
-
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: _______________________
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
-
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
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...
-
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
-
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...
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 :)
-
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 :)
-
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