标题: [转] 为GridView删除添加确认对话框
- temptation 2008-03-26 14:51 阅读:104
- 评论:1 查看评论 | 添加评论
① -----Template way-----
[图片]<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>

② -----RowDeleting method-----
[图片]protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
[图片][图片][图片]{
[图片]    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('确实要删除该记录吗?')");
[图片]    }
[图片]}

查看评论 | 添加评论
返回顶部 | 返回首页