gridview编辑失败 模板项中按钮中commandName也写update了
gridview编辑失败 模板项中按钮中commandName也写update了我实在不知道是怎吗回事
总是提示:
异常详细信息: System.ArgumentOutOfRangeException: 指定的参数已超出有效值的范围。
参数名: index
真无语了,哪位大哥大姐帮小弟解决一下 不胜感激!!!
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
string sqlcomm = "update UF_OWNERCOMM(UF_OWNERCOMM_NAME) values ('" + ((TextBox)(GridView1.Rows[e.RowIndex].Cells[2].Controls[0])).ToString() + "') where UF_OWNERCOMM_ID = '"+GridView1.DataKeys[e.RowIndex].Value.ToString()+"'";
SqlConnection myconn = new SqlConnection(publicclass.getconnstr());
myconn.Open();
int i = new SqlCommand(sqlcomm, myconn).ExecuteNonQuery(); ;
if (i>0)
{
Response.Write("<script>alert('更新成功')</script>");
}
else
{
Response.Write("<script>alert('更新失败')</script>");
}
myconn.Close();
GridView1.EditIndex = -1;
datebing();
}