指定的参数已超出有效值的范围。 参数名: index
protectedvoidGridView1_RowUpdating(objectsender,GridViewUpdateEventArgse){intOA_UID=i...
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
int OA_UID = int.Parse(GridView1.DataKeys[e.RowIndex].Value.ToString());
string OA_UName = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[1].Controls[0])).Text.ToString();//错误提示:指定的参数已超出有效值的范围。
参数名: index
string OA_UEmail = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[2].Controls[0])).Text.ToString();
string OA_Usex = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[3].Controls[0])).Text.ToString();
string OA_Upost = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[4].Controls[0])).Text.ToString();
string OA_Uaddress = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[5].Controls[0])).Text.ToString();
string OA_Uqq = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[6].Controls[0])).Text.ToString();
string sqlstr = "update userMessage set OA_UName='" + OA_UName + "', OA_UEmail='" + OA_UEmail + "', OA_Usex='" + OA_Usex + "', OA_Upost='" + OA_Upost + "', OA_Uaddress='" + OA_Uaddress + "', OA_Uqq='" + OA_Uqq + "' where OA_UID=" + OA_UID;
SqlConnection myConn = GetCon();
myConn.Open();
SqlCommand myCmd = new SqlCommand(sqlstr, myConn);
myCmd.ExecuteNonQuery();
myCmd.Dispose();
myConn.Close();
GridView1.EditIndex = -1;
GridViewBind();
}
怎么改? 展开
{
int OA_UID = int.Parse(GridView1.DataKeys[e.RowIndex].Value.ToString());
string OA_UName = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[1].Controls[0])).Text.ToString();//错误提示:指定的参数已超出有效值的范围。
参数名: index
string OA_UEmail = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[2].Controls[0])).Text.ToString();
string OA_Usex = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[3].Controls[0])).Text.ToString();
string OA_Upost = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[4].Controls[0])).Text.ToString();
string OA_Uaddress = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[5].Controls[0])).Text.ToString();
string OA_Uqq = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[6].Controls[0])).Text.ToString();
string sqlstr = "update userMessage set OA_UName='" + OA_UName + "', OA_UEmail='" + OA_UEmail + "', OA_Usex='" + OA_Usex + "', OA_Upost='" + OA_Upost + "', OA_Uaddress='" + OA_Uaddress + "', OA_Uqq='" + OA_Uqq + "' where OA_UID=" + OA_UID;
SqlConnection myConn = GetCon();
myConn.Open();
SqlCommand myCmd = new SqlCommand(sqlstr, myConn);
myCmd.ExecuteNonQuery();
myCmd.Dispose();
myConn.Close();
GridView1.EditIndex = -1;
GridViewBind();
}
怎么改? 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询