<ItemTemplate>
                                &nbsp;<asp:LinkButton ID="LinkButton1" CommandArgument='<%#DataBinder.Eval(Container.DataItem,"ID")%>' CommandName="Delete" runat="server">删除</asp:LinkButton>
                            </ItemTemplate>
---这个是html中的代码
 //绑定事件时激发
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
       if (e.Row.RowType == DataControlRowType.DataRow)
        {
            LinkButton l = (LinkButton)e.Row.FindControl("LinkButton1");
            l.Attributes.Add("onclick", "javascript:return confirm('确定要删除此用户吗?')");
        }    }    //生成事件时激发
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Delete")
        {
            if (e.CommandArgument != null)
            {
                UserInfo.Del(e.CommandArgument.ToString());
                this.GridViewInit();
            }
        }
    }问题:数据在数据库中是删除了,但它还是出现错误,错误提示是:GridView“GridView1”激发了未处理的事件“RowDeleting”。请哪位DG帮帮忙?????

解决方案 »

  1.   

    你需要在 GridView1_RowDeleting 中写代码阿。。
      

  2.   

    别写在 GridView1_RowCommand 中
      

  3.   

    添加一个 
    GridView1_RowDeleting 事件,
    在里面写一句话: e.Cancel = true;这样就搞定了!
      

  4.   

    或者你不要把 CommandName= "Delete"
    改成 "D" 之类的,就不会触发 RowDeteting 事件了!
      

  5.   

    我改了
     protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "delete")
            {
                if (e.CommandArgument != null)
                {
                    UserInfo.Del(e.CommandArgument.ToString());
                    this.GridViewInit();
                }
            }
        }