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