gridview 索引超出范围。必须为非负值并小于集合大小。!!!

问题描述

索引超出范围。必须为非负值并小于集合大小。参数名:index说明:执行当前Web请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。异常详细信息:System.ArgumentOutOfRangeException:索引超出范围。必须为非负值并小于集合大小。参数名:index拜求高手解决!!!程序如下!protectedvoidSearch_Click(objectsender,EventArgse){SqlConnectionmyConnection=newSqlConnection(ConfigurationManager.ConnectionStrings["sqlconnection"].ConnectionString);myConnection.Open();stringcmdText="SELECTUsers.RoleID,Users.BID,CheckDetail.CDID,CheckDetail.Sum,CheckDetail.CheckTime,Role.RoleNameFROMCheckDetailINNERJOINUsersONCheckDetail.UserID=Users.UserIDINNERJOINRoleONUsers.RoleID=Role.RoleIDWHEREChecked='"+lblUN.Text.Trim()+"'ANDCheckYear='"+ddlCY.Text.Trim()+"'";SqlCommandcmd=newSqlCommand(cmdText,myConnection);SqlDataReadersdr=cmd.ExecuteReader();GvUserList.DataSource=sdr;GvUserList.DataKeyNames=newstring[]{"CDID"};GvUserList.DataBind();sdr.Close();myConnection.Close();intRowsNum,i,CRoleID=0,CBID=0,Sum1gs=0,Sum2gs=0,Sum3gs=0,Sum4gs=0,Sum5gs=0,Sum6gs=0,Sum7gs=0,Sum8gs=0,Sum12gs=0,Sum13gs=0,Sum14gs=0,Sum15gs=0,Sum16gs=0;doubleSum=0.00,Sum1=0.00,Sum2=0.00,Sum3=0.00,Sum4=0.00,Sum5=0.00,Sum6=0.00,Sum7=0.00,Sum8=0.00,Sum12=0.00,Sum13=0.00,Sum14=0.00,Sum15=0.00,Sum16=0.00,Leader=0.00;RowsNum=GvUserList.Rows.Count;for(i=0;i<RowsNum;i++){CRoleID=Int32.Parse(GvUserList.Rows[i].Cells[3].Text);CBID=Int32.Parse(GvUserList.Rows[i].Cells[4].Text);//打分if(Int32.Parse(CRedID.Text)==6){switch(CRoleID){case2:{Sum2=Sum2+double.Parse(GvUserList.Rows[i].Cells[1].Text);Sum2gs=Sum2gs+1;}break;case3:{Sum3=Sum3+double.Parse(GvUserList.Rows[i].Cells[1].Text);Sum3gs=Sum3gs+1;}break;case7:{Sum7=Sum7+double.Parse(GvUserList.Rows[i].Cells[1].Text);Sum7gs=Sum7gs+1;}break;case8:{Sum8=Sum8+double.Parse(GvUserList.Rows[i].Cells[1].Text);Sum8gs=Sum8gs+1;}break;case12:{Sum12=double.Parse(GvUserList.Rows[i].Cells[1].Text);Sum12gs=1;}break;case13:{Sum13=double.Parse(GvUserList.Rows[i].Cells[1].Text);Sum13gs=1;}break;case16:{Sum16=Sum16+double.Parse(GvUserList.Rows[i].Cells[1].Text);Sum16gs=Sum16gs+1;}break;default:break;}Sum=Sum2+Sum3+Sum7+Sum8+Sum12+Sum13+Sum16}Label1.Text=Sum.ToString();}

解决方案

解决方案二:
索引超出范围。必须为非负值并小于集合大小。楼主,这种问题都解决不了???????????
解决方案三:
i<RowsNum-1
解决方案四:
新手!~见笑了我不知道哪里有错误啊!~望给予解决方法!谢谢了!~~!
解决方案五:
谢谢楼上的英雄了!~解决了!~
解决方案六:
既然问题解决了,就来接分
解决方案七:
i<RowsNum-1
解决方案八:
接分吧
解决方案九:
抢分..哈哈
解决方案十:
凑热闹
解决方案十一:
为什么我给分系统提示我密码验证有错误啊?

时间: 2024-09-15 13:29:12

gridview 索引超出范围。必须为非负值并小于集合大小。!!!的相关文章

C#索引超出范围.必须为非负值并小于集合大小

问题描述 _et=newList<List<edge>>(ymax-ymin+1);for(inti=0;i<_et.Count;i++){_et[i]=newList<edge>();}//边的分类表else{intj=(int)(_segments[i].p1.Y-ymin);edgeed=newedge();ed.x=_segments[i].p1.X;ed.deltax=(_segments[i].p2.X-_segments[i].p1.X)/(_seg

索引超出范围。必须为非负值并小于集合大小

问题描述 说明:执行当前Web请求期间,出现未处理的异常.请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息.异常详细信息:System.ArgumentOutOfRangeException:索引超出范围.必须为非负值并小于集合大小.参数名:index源错误:行81://取主键行82:行83:inttypeId=Convert.ToInt32(this.gvRoomType.DataKeys[e.RowIndex].Value);行84:boolres=BLL.RoomTy

C# 关闭Form时出错:索引超出范围。必须为非负值并小于集合大小

问题描述 System.ArgumentOutOfRangeException:索引超出范围.必须为非负值并小于集合大小.参数名:index在System.Collections.ArrayList.get_Item(Int32index)在System.Windows.Forms.DataGridViewColumnCollection.get_Item(Int32index)在System.Windows.Forms.DataGridView.PositionEditingControl(B

关于总分站,泛域名解析,报错索引超出范围。必须为非负值并小于集合大小。

问题描述 关于总分站,泛域名解析,报错索引超出范围.必须为非负值并小于集合大小.如这样没错http://gl.zm777.com/如这样没错http://gsdfdsfl.zm777.com/这样就错了,是什么问题啊 解决方案 解决方案二:帮顶.

gridview中gridview索引超出范围。必须为非负值并小于集合大小。 参数名: index,求帮助

问题描述 protectedvoidPage_Load(objectsender,EventArgse){stringstr="select*fromdbo.Medicine";dbconectiondb=newdbconection();DataSetds=db.DataAdapter(str);GridView2.DataSource=ds;GridView2.DataBind();GridView2.DataKeyNames=newstring[]{"mno"

SelectedCells索引超出范围。必须为非负值并小于集合大小

问题描述 网上搜了一下,说是表格点击选中的并非是整行,而是单个单元格是在vs2012里面进行的代码如下:publicpartialclassForm1:Form{publicForm1(){InitializeComponent();}SqlConnectionconn;DataSetds;SqlDataAdaptersda;privatevoidForm1_Load(objectsender,EventArgse){conn=newSqlConnection("DataSource=.;dat

索引超出范围。必须为非负值并小于集合大小。

问题描述 ublicClass数据存取类__EmployeeDA类PublicSharedEmployeesAsArrayList=NewArrayListSharediAsIntegerPublicSharedReadOnlyPropertygetConnectionStringAsStringGetDimstrConnAsStringstrConn&="DataSource=(local);"strConn&="InitialCatalog=Northwi

System.ArgumentOutOfRangeException: 索引超出范围。必须为非负值并小于集合大

问题描述 索引超出范围.必须为非负值并小于集合大小.参数名:index说明:执行当前Web请求期间,出现未经处理的异常.请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息.异常详细信息:System.ArgumentOutOfRangeException:索引超出范围.必须为非负值并小于集合大小.参数名:index源错误:行192:SqlConnectionconn=newSqlConnection(connectString);行193:conn.Open();行194:s

删除-急!!!!index;索引超出范围。必须为非负

问题描述 急!!!!index;索引超出范围.必须为非负 protected void GridView2_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "shanchu") //如果单击的是"选修"按钮 { int index = Convert.ToInt32(e.CommandArgument.ToString()); //取出选修课程所在的行索引 Da