<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<asp:LinkButton runat="server" CausesValidation="False" CommandName="Delete"
Text="删除" OnClientClick='return confirm("Are you sure you want to delete this record?");'></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<ItemTemplate>
<asp:LinkButton runat="server" CausesValidation="False" CommandName="Delete"
Text="删除" OnClientClick='return confirm("Are you sure you want to delete this record?");'></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
② -----RowDeleting method-----
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
Response.Write("<script>window.confirm('确定删除吗?');</script>");
}
{
Response.Write("<script>window.confirm('确定删除吗?');</script>");
}
③ -----RowDataBound method-----
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
((LinkButton)e.Row.Cells[4].Controls[0]).Attributes.Add("onclick", "return confirm('确实要删除该记录吗?')");
}
}
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
((LinkButton)e.Row.Cells[4].Controls[0]).Attributes.Add("onclick", "return confirm('确实要删除该记录吗?')");
}
}