问题描述
索引超出范围。必须为非负值并小于集合大小。参数名: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
解决方案八:
接分吧
解决方案九:
抢分..哈哈
解决方案十:
凑热闹
解决方案十一:
为什么我给分系统提示我密码验证有错误啊?