Click here to Skip to main content
15,867,999 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to update textbox of gridview which is in item template and should save the value atomatically in database..please give me any idea..
Posted
Comments
Nandakishore G N 14-Mar-13 7:10am    
use gridview rowcommand event..

Hi


You have to write the update statement in the update button click event



C#
GridViewRow row = (GridViewRow)GridView4.Rows[e.RowIndex];
          TextBox txt_olodge = (TextBox)row.FindControl("txt_od");


SQL
update tablename set lodge='" + txt_od.Text + "'
 
Share this answer
 
v2
You need to do the following:
Steps:
1. Loop through the GridView Rows.
2. Find The TextBox which is in ItemTemplate.
3. Take the value of that TextBox and update it where ever you want(Your database).

To loop through gridview try the code snippet below:
C#
foreach (GridViewRow r in YourGridView.Rows)
{
    //Find the textbox and update the value here
}


--Amit
 
Share this answer
 
Comments
ujali 14-Mar-13 7:46am    
but my save or say update button is outside the grid...then how should i do ..and particular row should get updated..
_Amy 14-Mar-13 7:47am    
On click of save button only you need to loop through the grid.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900