gridview 删除行时出现指定的参数已超出有效值的范围问题
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
string sqlconstr = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
SqlConnection sqlconn = new SqlConnection(sqlconstr);
sqlconn.Open();
//删除行处理
String sql = "delete from consumer where name=@name" + ((TextBox)GridView1.Rows[e.RowIndex].Cells[0].Controls[0]).Text);//删除语句
SqlCommand Comm = new SqlCommand(sql, sqlconn);
// Comm.Parameters.AddWithValue("@name",((TextBox)GridView1.Rows[e.RowIndex].Cells[0].Controls[0]).Text);
Comm.ExecuteNonQuery();
sqlconn.Close();
sqlconn = null;
Comm = null;
GridView1.EditIndex = -1;
bindgrid();
}
总是显示:异常详细信息: System.ArgumentOutOfRangeException: 指定的参数已超出有效值的范围。
但 在编辑更新中相同代码((TextBox)GridView1.Rows[e.RowIndex].Cells[0].Controls[0]).Text却没有错,并没有出现什么超出有效范围,这是什么情况?求大神帮忙!感谢!