读书人

当小弟我对GridView里面的某一项删除的

发布时间: 2011-12-22 23:36:25 作者: rapoo

当我对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();

读书人网 >asp.net

热点推荐