Gridview控件添加编辑按钮时候需编写的函数》
来源:互联网 发布:linux将文件夹压缩 编辑:程序博客网 时间:2024/04/29 00:02
protectedvoid GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
GridView1.EditIndex = e.NewEditIndex;
bind();
}
protectedvoid GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
sqlcon =new SqlConnection(strCon);
string sqlstr ="update tb_Member set name='"
+ ((TextBox)(GridView1.Rows[e.RowIndex].Cells[1].Controls[0])).Text.ToString().Trim() +"',sex='"
+ ((TextBox)(GridView1.Rows[e.RowIndex].Cells[2].Controls[0])).Text.ToString().Trim() +"',nPlace='"
+ ((TextBox)(GridView1.Rows[e.RowIndex].Cells[3].Controls[0])).Text.ToString().Trim() +"' where id='"
+ GridView1.DataKeys[e.RowIndex].Value.ToString() +"'";
sqlcom=new SqlCommand(sqlstr,sqlcon);
sqlcon.Open();
sqlcom.ExecuteNonQuery();
sqlcon.Close();
GridView1.EditIndex =-1;
bind();
}
protectedvoid GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
GridView1.EditIndex =-1;
bind();
}
publicvoid bind()
{
string sqlstr ="select * from tb_Member";
sqlcon =new SqlConnection(strCon);
SqlDataAdapter myda =new SqlDataAdapter(sqlstr, sqlcon);
DataSet myds =new DataSet();
sqlcon.Open();
myda.Fill(myds, "tb_Member");
GridView1.DataSource = myds;
GridView1.DataKeyNames =newstring[] { "id" };
GridView1.DataBind();
sqlcon.Close();
}
- Gridview控件添加编辑按钮时候需编写的函数》
- 手动绑定的GridView控件,“编辑”“删除”按钮的委托代码怎么写
- 不使用GridView自带编辑删除等等按钮,放置服务器控件的按钮。获取点击按钮的当前行以便进行编辑删除
- 在gridview编辑中添加dropdownlist控件并使其为数据库的默认值
- 给VS2005的GridView控件自带的删除按钮添加确认
- Gridview:在进入编辑模式后动态添加控件
- 验证GridView控件编辑列的值
- GridView控件的编辑和删除(未完)
- GridView控件的编辑、删除、更新、取消!
- 在GridView控件中添加相关的操作字段/操作按钮
- GridView添加编辑模板
- gridview动态添加按钮
- easyui添加编辑按钮
- 编写可编辑的List控件
- GridView自带删除编辑功能的事件编写
- 自定义按钮控件的简单编写
- 调用函数的时候不能禁用按钮
- Gridview添加Checkbox控件的使用
- 开放平台其实是一种B2B模式
- 一条查询某一条数据是整个表中的第几条数据的SQL
- BIN文件与NB0的区别
- 《Microsoft Sql server 2008 Internals》读书笔记--第三章Databases and Database Files(2)
- Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: startIndex
- Gridview控件添加编辑按钮时候需编写的函数》
- ImportError: No module named vtkCommonPython
- 编译生成的kernel说明
- 简单状态机Workflow基于Web应用
- 在MFC程序里打开和关闭另一个程序
- 嵌入式设备上黑颜色的显示
- 给VB.NET开发者的46个忠告
- 下拉框链接到网页
- UI Automation-ValuePattern