更新时间:2023-02-11 21:01:22
protected void GridView1_RowUpdating( object sender,GridViewUpdateEventArgs e)
{
// 找到你想要的值的值控件
TextBox tb =(TextBox)GridView1.Rows [e.RowIndex] .FindControl( txtCityEdit);
}
行更新事件你可以读取网格视图控件,读取控件值并绑定到你想要的位置,试试此
I when i run my code it displays a form and a gridview (displaying all the database records) and when i click on edit in my gridview i want all the data gets filled in the form and when i submit that form it gets updated both in the database and gridview.
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { //find the value control who's value you want TextBox tb = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtCityEdit");
}
on row Updating event u can read the grid view controls, read the control values and bind to where you want, try this.
Please follow the link, you will get some hints how to update in gridview
Implementing Cumulative total and Select All functionality with Events in ASP.NET GridView[^]
Thanks