在GridView控件中刪除數據
来源:互联网 发布:类似360的软件 编辑:程序博客网 时间:2024/06/08 14:27
添加一個CommandField列并指明為“刪除”按鈕(默認為LinkButton按鈕),單擊該按鈕時將觸發RowDeleting事件。
例如:
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
string sqlStr = "delete from tb_Member where id = '" + GridView1.DataKeys[e.RowIndex].Value.ToString() + "'";
sqlConn = new SqlConnection(strConn);
sqlCmd = new SqlCommand(sqlStr, sqlConn);
sqlConn.Open();
sqlCmd.ExecuteNoQuery();
sqlConn.Close();
bind();
}
單擊刪除按鈕時可以設置彈出一個確認提示框,例如:
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
if(e.Row.RowType == DataControlRowType.DataRow)
{
((LinkButton)(e.Row.Cell[4].Controls[0])).Attributes.Add("onclick", "return confirm('確認要刪除嗎?')");
}
}
- 在GridView控件中刪除數據
- GridView中ButtonLinkField的刪除提示
- 直接在GridView中编辑CheckBox控件
- 在GridView控件中使用TemplateField
- 在GridView控件中使用TemplateField
- 在GridView中遍历寻找控件
- 在GridView控件中使用TemplateField
- GridView刪除確認
- GridView刪除確認
- ASP.net中在gridview中绑定dropdownlist控件
- dev中gridview控件
- 使用GridView控件在数据库中插入数据
- GridView Template 在EditItemTemplate中添加验证控件
- 在 GridView 控件中添加一列复选框
- 在绑定控件中(datagrid,gridview..)加checkbox
- 【.net】在GridView控件中添加确认删除对话框
- 在 GridView 控件中添加一列复选框
- 在GridView控件中CheckBoxFiled如何添加复选框
- permission和uses-permission的区别
- mysql 表碎片整理
- web 测试(二 )性能测试(包括负载/压力测试)
- C#高级编程 读书点
- VC PlaySound
- 在GridView控件中刪除數據
- mongo参考教程链接
- xml-rpc
- Android This text field does not specify an inputType or a hint 解决
- Refactoring Game Entities with Components
- Android中的Handler总结
- Windows Phone 页面跳转事件调用顺序
- Linux下gcc编译中关于头文件与库文件搜索路径相关问题
- 6款常用的Java开源报表制作工具