小弟是个菜鸟,想请教一个很菜的问题。
在GridView1_RowDeleting 事件中弹出确认、取消对话框,
如果用户点了确定,就执行删除的事件,否则是什么也不执行,这样写: this.RegisterStartupScript("confirm", "<script>window.confirm('若要进行单击确定,否则请单击取消');</script>");
不行的哦。各位大哥,帮忙告诉小弟吧,应该怎么写.
谢谢啦。

解决方案 »

  1.   

    用一个linkbutton做示范
    this.LinkButton1.Attributes.Add("onclick","return  confirm('您确定要进行【删除】操作吗?');" );
      

  2.   

    GridView1_RowDeleting 的事件里执行的,我不想用按钮来做。那该如何写呢?
      

  3.   

    在前台用js写
    <a href="javascript: DeleteOneProduct('<%# Eval("intID") %>')">删除</a>        function DeleteOneProduct(tempID) {
                if (confirm("您确认删除所选调查?")) {
           你的操作!            }
            }
      

  4.   

     protected void gv_user_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                if (e.Row.RowState == DataControlRowState.Normal || e.Row.RowState == DataControlRowState.Alternate)
                {
                    LinkButton delte = (LinkButton)e.Row.FindControl("LinkButton1");
                    delte.Attributes.Add("onclick", "return confirm('你确定要删除该纪录吗?');");
                }
            }
        }那就参考这个吧
      

  5.   

    http://blog.csdn.net/21aspnet/archive/2007/03/25/1540301.aspx
      

  6.   

    就是把这个写在删除事件里啊,在GridView得有个删除按钮吧?这是最人性化的做法,否则也肯用CheckBox替代,选中就删除,那样的话有点恐怖,即使有这个确认对话框也会给用户带来心理上的冲击
      

  7.   

    安装一套AJAX.NET的控件吧..这是一个很简单的功能
      

  8.   

    执行删除的 提示要在 RowDataBound 里写
     protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            //
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                LinkButton l = (LinkButton)e.Row.FindControl("LinkButton1");            string a = "确认删除该用户?"; //e.Row.Cells[1].Text; //第二列的值             e.Row.Cells[4].Attributes.Add("onclick", "return confirm('" + a + "');");     //删除时给出提示 ,其中 4 为点击的删除链接的 列的索引值,需要你的索引替换        }    }
      

  9.   

    在CommandField属性里 设置DeleteText为
    <div onclick="JavaScript:return confirm('确定删除吗?')">删除</div>
      

  10.   

    楼上的都挺好的,记得把删除按钮转换为模版列
    或者直接在aspx页面的删除按钮属性里加上onclientclick="return confirm('确认要删除吗?')";
      

  11.   

    执行删除的 提示要在 RowDataBound 里写 
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) 
        { 
            // 
            if (e.Row.RowType == DataControlRowType.DataRow) 
            { 
                LinkButton l = (LinkButton)e.Row.FindControl("LinkButton1");             string a = "确认删除该用户?"; //e.Row.Cells[1].Text; //第二列的值             e.Row.Cells[4].Attributes.Add("onclick", "return confirm('" + a + "');");    //删除时给出提示 ,其中 4 为点击的删除链接的 列的索引值,需要你的索引替换         }     }