GridView更新操作问题
来源:互联网 发布:单片机应用技术 推荐 编辑:程序博客网 时间:2024/05/22 12:38
在RowUpdating的事件里,怎么样获取
<asp:BoundField> </asp:BoundField>
里的值???
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
try
{
GridViewRow myrow = GridView1.Rows[e.RowIndex];
string name = ((TextBox)myrow.Cells[1].Controls[0]).Text;
string pwd = ((TextBox)myrow.Cells[2].Controls[0]).Text;
string sql = "update dc4_user_def set username= ' " + name + " ',password= ' " + pwd + " 'where userid= ' " + userid + " ' ";
DBHelper.ExcuteQuery(sql);
GridView1.EditIndex = -1;
this.BindGridView();
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}
<asp:BoundField> </asp:BoundField>
里的值???
方法1:
try something like
GridViewRow row = GridView1.Rows[e.RowIndex];
if (row != null)
{
TextBox tb = row.Cells[n].Controls[0] as TextBox; //change n to the position of your bound field
if (tb != null)
{
Response.Write(tb.Text);
}
}
GridViewRow row = GridView1.Rows[e.RowIndex];
if (row != null)
{
TextBox tb = row.Cells[n].Controls[0] as TextBox; //change n to the position of your bound field
if (tb != null)
{
Response.Write(tb.Text);
}
}
或
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
try
{
GridViewRow myrow = GridView1.Rows[e.RowIndex];
string name = ((TextBox)myrow.Cells[1].Controls[0]).Text;
string pwd = ((TextBox)myrow.Cells[2].Controls[0]).Text;
string sql = "update dc4_user_def set username= ' " + name + " ',password= ' " + pwd + " 'where userid= ' " + userid + " ' ";
DBHelper.ExcuteQuery(sql);
GridView1.EditIndex = -1;
this.BindGridView();
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}
- GridView更新操作问题
- GridView局部更新问题
- gridview 下拉DropDownList 更新操作
- gridview手写更新数据操作
- gridview中的删除 更新操作
- GridView 的添加,删除,更新 操作
- GridView基本的编辑,更新,删除操作
- GridView基本的编辑,更新,删除操作
- GridView基本的编辑,更新,删除操作
- GridView基本的操作 编辑 更新 取消
- 关于GridView修改,更新,删除操作
- GridView的更新删除操作新篇一
- DevExpress Gridview数据源更新几个简单操作
- GridView的删除和更新问题
- GridView的删除和更新问题
- GridView的删除和更新问题
- GridView、ListView数据更新图片闪烁问题
- 在GridView中应该用分页、编辑、删除、更新操作
- tomcat发布javaEE项目的两种方式
- 读《代码大全》笔记:需求核对表
- 通过经纬度计算俩点之间的距离
- 链表之循环链表、双向链表
- 万兆网络设备
- GridView更新操作问题
- Apache----DBUtils框架
- iSCSI的配置(target/initiator)
- Windows X64上强制用x86模式运行c#程序
- crc error systerm resetting
- android intent和intent action大全
- C语言宏定义使用技巧
- CHM格式帮助文档乱码解决办法
- HDMI/DVI设备热插拨检测