ASp.NET 2.0中的GridView,添加GridView的RowDataBound事件并添加以下类似代码
注意:Cells[10]为删除按钮所在的列,删除按钮要在一个单独的列中,可以转化为模板列。
<asp:CommandField ShowDeleteButton="True" />
protected void GVColors_RowDataBound(object
sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
e.Row.Cells[10].Attributes.Add("onclick", "javascript:return confirm('你确认要删除/"" + e.Row.Cells[1].Text + "/"吗?')");
}
{
if (e.Row.RowType == DataControlRowType.DataRow)
e.Row.Cells[10].Attributes.Add("onclick", "javascript:return confirm('你确认要删除/"" + e.Row.Cells[1].Text + "/"吗?')");
}
注意:Cells[10]为删除按钮所在的列,删除按钮要在一个单独的列中,可以转化为模板列。