GridView增删改查之RowCommand事件
2012-05-12 15:14
274 查看
前台页面代码:
1.在GridView模板列中,添加LinkButton控件(只要是模板控件就行);
2.在LinkButton控件的属性:
CommandName属性:del/editor/search/add //可以自定义
CommandArgument属性:<%#Eval("ID")%>要绑定的值
后台CS代码:
protected void gdvBusiness_RowCommand(object sender, GridViewCommandEventArgs e)
{
switch (e.CommandName.ToLower())
{
case "del"://删除
BusinessManager.Del(Convert.ToInt32(e.CommandArgument));
BindGridView();
break;
case "editor"://修改
Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>location.href='BuesinessEditor.aspx?id=" + int.Parse(e.CommandArgument.ToString()) + "';</script>");
break;
case "search"://查询
Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>location.href='BuesinessInfo.aspx?id=" + int.Parse(e.CommandArgument.ToString()) + "';</script>");
break;
case "add"://增加
Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>location.href='BuesinessAdd.aspx';</script>");
break;
default:
break;
}
}
1.在GridView模板列中,添加LinkButton控件(只要是模板控件就行);
2.在LinkButton控件的属性:
CommandName属性:del/editor/search/add //可以自定义
CommandArgument属性:<%#Eval("ID")%>要绑定的值
后台CS代码:
protected void gdvBusiness_RowCommand(object sender, GridViewCommandEventArgs e)
{
switch (e.CommandName.ToLower())
{
case "del"://删除
BusinessManager.Del(Convert.ToInt32(e.CommandArgument));
BindGridView();
break;
case "editor"://修改
Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>location.href='BuesinessEditor.aspx?id=" + int.Parse(e.CommandArgument.ToString()) + "';</script>");
break;
case "search"://查询
Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>location.href='BuesinessInfo.aspx?id=" + int.Parse(e.CommandArgument.ToString()) + "';</script>");
break;
case "add"://增加
Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>location.href='BuesinessAdd.aspx';</script>");
break;
default:
break;
}
}
相关文章推荐
- GridView.RowCommand 事件
- gridview 中模板列无法响应row_command事件
- GridView中的RowCommand与Sorting事件的一些问题
- GridView RowCommand事件操作Demo Code
- GridView RowCommand事件操作Demo Code
- GridView使用之RowCommand事件的使用
- GridView RowCommand事件中取得當前行
- GridView.RowCommand 事件中获取当前行的信息
- GridViewRow可以任意位置单击引发事件的方法
- GridViewRow可以任意位置单击引发事件的方法!
- 引用 使用AspxGridView的FocusedRowChanged客户端事件取行值的注意事项
- DEV-aspxgridview行客户端单击双击事件RowClick、RowDblClick 、
- ASPX页面如何获取ASPxGridView的FocusedRowChanged事件?
- **GridView**在GridView的RowCommand里取列的值
- GridViewRow可以任意位置单击引发事件的方法
- ASP.NET DEMO 5:如何在GridView的RowCommand事件中获取当前的GridViewRow
- RecyclerView 使用总结(三):点击事件、GridView等、瀑布流、动态增删
- winform中datagridview事件RowPrePaint中类似与webform中的gridview的rowdatabound事件
- GridView的RowCreated与RowDataBound事件区别
- GridView RowCommand 获取列值