DataGrid:
直接设置删除列的文本为:
<div id="de" onclick="JavaScript:return confirm('确定删除吗?')">删除</div>
或者
<span id="de" onclick="JavaScript:return confirm('确定删除吗?')">删除</span>
此方法只能对删除列的ButtonType属性为Link有效,如果是图片的话得要在后台代码设置。
GridView:
如果 删除列的ButtonType属性为Link,那么直接设置其DeleteText属性设为:
<div id="de" onclick="JavaScript:return confirm('确定删除吗?')">删除</div>
或
<span id="de" onclick="JavaScript:return confirm('确定删除吗?')">删除</span>
如果删除列的ButtonType属性为Image,那么上面的方法就无效了,得在后台写代码:

Code
protected void gvCustom_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#ccddee'");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor");
//设置悬浮鼠标指针形状为"小手"
e.Row.Attributes["style"] = "Cursor:hand";
ImageButton imgFlag = new ImageButton();
imgFlag = ((ImageButton)e.Row.Cells[7].Controls[0]);
if (imgFlag.AlternateText == "删除")
{
imgFlag.Attributes.Add("onclick", "javascript:return confirm('您确信要删除吗!?')");
//Button btn = (Button)e.Row.Cells[5].Controls[0];
//btn.Attributes.Add("onclick", "javascript:return confirm('你确认要删除:\"" + e.Row.Cells[1].Text + "\"吗?')");
//Button1.Attributes.Add("onclick","return confirm(’确认?’)");
//button.attributes.add("onclick","if(confirm(’are you sure
?’)){return true;}else{return false;}")
}
}
}