用asp.net编写页面,GridView控件中update存在问题,指定的参数已超出有效值的范围。 参数名: index 说明: 执行当前 Web 请求期间,出现未经处理的异常。跪求大佬
指定的参数已超出有效值的范围。
参数名: index
说明: 执行当前 Web 请求期间,出现未经处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.ArgumentOutOfRangeException: 指定的参数已超出有效值的范围。
参数名: index
源错误:
行 50: cm.Parameters.Add(new SqlParameter("@Student_id", SqlDbType.VarChar, 50)); 行 51: String colvalue; 行 52: colvalue = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[1].Controls[0])).Text.ToString(); 行 53: cm.Parameters["@Student_name"].Value = colvalue; 行 54: colvalue = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[2].Controls[0])).Text.ToString(); |
源文件: C:\Users\罗坤\Desktop\Solution1\WebApplication2\student.aspx.cs 行: 52
堆栈跟踪:
[ArgumentOutOfRangeException: 指定的参数已超出有效值的范围。 参数名: index] System.Web.UI.ControlCollection.get_Item(Int32 index) +9822717 WebApplication2.student.GridView1_RowUpdating(Object sender, GridViewUpdateEventArgs e) in C:\Users\罗坤\Desktop\Solution1\WebApplication2\student.aspx.cs:52 System.Web.UI.WebControls.GridView.OnRowUpdating(GridViewUpdateEventArgs e) +122 System.Web.UI.WebControls.GridView.HandleUpdate(GridViewRow row, Int32 rowIndex, Boolean causesValidation) +792 System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +877 System.Web.UI.WebControls.GridView.RaisePostBackEvent(String eventArgument) +201 System.Web.UI.WebControls.GridView.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +15 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +15 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +9884558 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1639 |
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
SqlCommand cm = new SqlCommand("update_student_1", cn);
cm.CommandType = CommandType.StoredProcedure;
cm.Parameters.Add(new SqlParameter("@Student_name", SqlDbType.VarChar, 50));
cm.Parameters.Add(new SqlParameter("@Student_sex", SqlDbType.Char, 5));
cm.Parameters.Add(new SqlParameter("@Student_birthday", SqlDbType.DateTime, 8));
cm.Parameters.Add(new SqlParameter("@Student_id", SqlDbType.VarChar, 50));
String colvalue;
colvalue = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[1].Controls[0])).Text.ToString();
cm.Parameters["@Student_name"].Value = colvalue;
colvalue = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[2].Controls[0])).Text.ToString();
cm.Parameters["@Student_sex"].Value = colvalue;
colvalue = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[3].Controls[0])).Text.ToString();
cm.Parameters["@Student_birthday"].Value = colvalue;
cm.Parameters["@Student_id"].Value = GridView1.DataKeys[e.RowIndex].Value.ToString();
cm.Connection.Open();
try
{
cm.ExecuteNonQuery();
Lbl_note.Text = "编辑成功";
GridView1.EditIndex = -1;
}
catch (SqlException)
{
Lbl_note.Text = "编辑失败,请检查输入!";
Lbl_note.Style["color"] = "red";
}
cm.Connection.Close();
Bindgrid();
}
- .net webservice 因 URL 意外地以“/GetAllArticle”结束,请求格式无法识别。 说明: 执行当前 Web 请求期间,出现未经处理的异常。请检查堆栈跟踪信息,以了解有关该
- 对象的当前状态使该操作无效 说明: 执行当前 Web 请求期间,出现未处理的异常。
- 无法验证数据。执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息
- asp.net Chartr控件异常: System.Web.HttpException: 为 ChartImg.axd 执行子请求时出错(已解决)
- C#.NET 中使用gridview删除列出现“索引超出范围。必须为非负值并小于集合大小。参数名: index”
- GridView的HyperLinkField的DataNavigateUrlFormatString如何使用自定义的变量,而不是数据库绑定的值.报错:指定的参数已超出有效值的范围。参数名: index
- Gridview中隐藏某行出现“指定的参数已超出有效值的范围”
- win8下的IIS启动配置(ASP.NET - WEB APP指定的参数已超出有效值的范围,参数名:site)
- 处理 ASP.NET Chart 控件出错 为 ChartImg.axd 执行子请求时出错
- IIS处理Asp.net请求和Asp.net页面生命周期说明
- Asp.net开发心得点滴[动态加载的用户控件使用事件委托,交给页面处理的事件无效问题]
- ASP.NET Web页面(.aspx)添加用户控件(.ascx)无显示的问题
- ASP.NET 页面传递URL 指定的参数 不存在 时异常。怎么做判断
- GridView控件删除记录时出现索引超出范围问题的解决
- ASP.NET UpdatePanel页面异常提示处理
- SQLite数据库指令参数出现中文引起执行异常问题处理
- (转载)Win7的IIS配置asp.net出现“由于 Web 服务器上的“ISAPI 和 CGI 限制”列表设置,无法提供您请求的页面。
- GridView控件删除记录时出现索引超出范围问题的解决
- Win7的IIS配置asp.net出现“由于 Web 服务器上的“ISAPI 和 CGI 限制”列表设置,无法提供您请求的页面。”(图文解决方法)
- asp.net学习笔记异常处理001---.framework4.0中asp.net页面ValidateRequest="false" 无效的问题