如何在gridview编辑中获取表单文本字段中的值,并在gridview中提交值 [英] how to get values in form textfield on gridview edit and on submit the value get changed in the gridview

查看:139
本文介绍了如何在gridview编辑中获取表单文本字段中的值,并在gridview中提交值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行我的代码时,它会显示一个表单和一个gridview(显示所有数据库记录),当我在gridview中单击编辑时,我希望所有数据都填写在表单中,当我提交该表单时,它获取在数据库和gridview中都进行了更新。

解决方案

  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


这篇关于如何在gridview编辑中获取表单文本字段中的值,并在gridview中提交值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆