GridView点击删除后弹对话框再删除
添加一个模版列,编辑模版列,并加入一个linkButton ,在onClientClick中加入JavaScript:return
confirm(‘你确定要删除该行记录吗?’);
在html中找到那个模版列在其中加入这个属性CommandArgument=‘<%# Bind(“ID”) %>’
选中LinkButton的事件在Command项中写delete然后在后台代码中这样实现:
protected void delete( object sender, CommandEventArgs e)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBloc
kStart.gif) ![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/
ContractedBlock.gif) … {
string ID = e.CommandArgument.ToString(); // 得到该行的ID值(如果你下面的调用是通过ID来删除的话)
if (deviceInfoBLL.Delete(ID)) // 这里是调用下层的删除方法
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubB
lockStart.gif) ![](http://images.csdn.net/syntaxhighlighting/OutliningIndicato
rs/ContractedSubBlock.gif) … {
init(); // 初始化页面
Label_warning.Text = " 删除成功,编号为: " + ID;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubB
lockEnd.gif) }
else
Label_warning.Text = " 删除失败,编号为: " + ID;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBloc
kEnd.gif) }
完成