读书人

GridView删除数据的有关问题

发布时间: 2011-12-26 23:09:58 作者: rapoo

GridView删除数据的问题

C# code
protected void gvTourInfo_RowCommand(object sender, GridViewCommandEventArgs e)    {        Business busi = new Business();        if (e.CommandName == "Delete")        {            int ID = Convert.ToInt32(e.CommandArgument);            if (busi.DelectYudingInfo(ID) > 0)            {                Response.Write("<script> alert('你已删除成功!'); </script>");            }            else            {                Response.Write("<script> alert('删除失败!'); </script>");            }        }        this.gvTourInfo.EditIndex = -1;        BindData();    }


为什么不能删除啦,错误信息是未激活RowDeleteing事件

[解决办法]
如果你想自定义删除过程,那就不要把CommandName设成Delete,像Select, Insert, New, Update, Delete这几个都可以看作是‘关键字’。起别的名字吧。

读书人网 >asp.net

热点推荐