且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在gridview编辑中获取表单文本字段中的值,并在gridview中提交值

更新时间:2023-02-11 21:01:22

  protected   void  GridView1_RowUpdating( object  sender,GridViewUpdateEventArgs e)
{
// 找到你想要的值的值控件
TextBox tb =(TextBox)GridView1.Rows [e.RowIndex] .FindControl( txtCityEdit);





}



行更新事件你可以读取网格视图控件,读取控件值并绑定到你想要的位置,试试此


请点击链接,你会得到一些如何在gridview中更新的提示



使用ASP.NET GridView中的事件实现累计总计和全选功能 [ ^ ]



谢谢


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