GridView模板列添加删除按钮
2013-01-17 09:47
423 查看
GridView模板列添加删除按钮
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="job_id" OnRowCommand="GridView1_RowCommand" > <Columns> <asp:BoundField DataField="job_id" /> <asp:BoundField DataField="max_lvl" /> <asp:BoundField DataField="min_lvl" /> <asp:ButtonField ButtonType="Button" CommandName="aa" Text="删除" /> </Columns> </asp:GridView> 在GridView里面添加个ButtonField 类型是Button的 ,还有关联事件名要起一个名字,因为后面删除要用到这个 protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "aa")//aa是关联的事件名 { int index = Convert.ToInt32(e.CommandArgument);//获取命令的参数 int iLeagueID = Convert.ToInt32(this.GridView1.DataKeys[index].Value);//获取当前点击列的ID号 Response.Write( "<script>alert('" + iLeagueID + "')</script>"); } } |
相关文章推荐
- Gridview添加自定义删除按钮
- 带添加按钮的GridView,item的删除事件
- GridView中给删除按钮添加确认对话框
- gridview 控件添加删除按钮(二)
- GridView模板列中添加CheckBox 实现全选、删除
- 给GridView删除按钮添加提示框
- 为gridview删除按钮添加确认窗口
- 【转】给GridView删除按钮添加提示框
- GridView添加删除按钮终极办法
- GridView 添加、删除、编辑按钮问题
- ASP.NET GridView用法(二) 模板,脚注,排序,编辑,删除,多选,分页,添加
- 给VS2005的GridView控件自带的删除按钮添加确认
- 在昨天作业的基础上添加 :删除按钮,修改并保存按钮 和 添加按钮。完成这些按钮所对应的功能/新建页面DataXML,使用GridView显示book.xm中的图书信息
- 在GridView控件中添加对记录的删除按钮
- 在GridView模板列中添加按钮和事件 使用CommandArgument存取
- 为GRIDVIEW“删除”列和Button按钮添加确认对话框
- GridView 中如何给删除按钮添加提示
- asp.net中gridview中模板“删除”按钮 ,删除点击行
- GridView 中如何给删除按钮添加提示
- 转:GridView 中如何给删除按钮添加提示