1.模板列。
<asp:LinkButton ID="LinkButton2" runat="server" CommandName="delete" CausesValidation="False" OnClientClick="return confirm('确认要删除吗?');">删除</asp:LinkButton>
2.非模板列
在RowDataBound事件中进行,若Delete按钮是LinkButton,并且在第3列,代码如下:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { ((LinkButton)e.Row.Cells[2].Controls[0]).Attributes.Add("onclick", "return confirm('确认删除吗?')"); } }