当前位置: 代码迷 >> ASP.NET >> 当小弟我对GridView里面的某一项删除的是后出现下面的错误
  详细解决方案

当小弟我对GridView里面的某一项删除的是后出现下面的错误

热度:6037   发布时间:2013-02-26 00:00:00.0
当我对GridView里面的某一项删除的是后出现下面的错误。
当我对GridView里面的某一项删除的是后出现下面的错误.


  protected   void   GridView1_PageIndexChanging(object   sender,   GridViewPageEventArgs   e)
        {
                this.GridView1.PageIndex   =   e.NewPageIndex;
                this.bind();
        }
        protected   void   GridView1_RowDeleting(object   sender,   GridViewDeleteEventArgs   e)
        {
                SqlConnection   strcon   =   new   SqlConnection(System.Configuration.ConfigurationManager.AppSettings[ "conn "]);
                strcon.Open();
                string   id   =   this.GridView1.DataKeys[e.RowIndex].Value.ToString();
                SqlCommand   comm   =   new   SqlCommand( "delete   from   tb_suggestion   where   id= "   +   id,   strcon);
                comm.ExecuteNonQuery();
                strcon.Close();
               
        }




------解决方案--------------------------------------------------------
在delete以后重新绑定一下
加上
...
comm.ExecuteNonQuery();
strcon.Close();
this.bind();