您的位置:首页 > 其它

如何在GridView中进行删除操作时弹出提示问是否确认删除?

2012-12-28 11:25 453 查看
第一种解决方案:

先把你的删除按钮的那一列转化为模板列,然后再模板编辑里找到删除按钮,在你的删除按钮的OnclientClick属性中添加:

return confirm("确定删除?")

第二种解决方案:

点击GridView控件左上角的智能标记,选择编辑列,在出现的对话框中点击CommandField,选择删除按钮,点击添加,然后回到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('您真的要删除这条记录吗?')");

}

}

}

}

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐