GridView中删除行的提示
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
foreach (TableCell tc in e.Row.Cells)
{
if (tc.Controls.Count > 0)
{
foreach (Control con in tc.Controls)
{
if (con.GetType().ToString() == "System.Web.UI.WebControls.DataControlLinkButton")
{
LinkButton lb = (LinkButton)con;
if (lb.CommandName == "Delete")
{
lb.Attributes.Add("onclick", "return confirm('您真的要删除这条记录吗?')");
}
}
}
}
}
}
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
foreach (TableCell tc in e.Row.Cells)
{
if (tc.Controls.Count > 0)
{
foreach (Control con in tc.Controls)
{
if (con.GetType().ToString() == "System.Web.UI.WebControls.DataControlLinkButton")
{
LinkButton lb = (LinkButton)con;
if (lb.CommandName == "Delete")
{
lb.Attributes.Add("onclick", "return confirm('您真的要删除这条记录吗?')");
}
}
}
}
}
}
请问有没有更好的方法?

浙公网安备 33010602011771号