急 急 急!在线考试系统 随机单选试题判断单选试题成绩出错,说超出索引.判断代码应该怎么写.求高手帮忙
下面红字所标地方运行时提示超出索引,求各位高手帮忙.(判断随机单选题成绩)
'计算单选题成绩
int_row11 = 0
int_row11Point = 0
For Each answer1 As DataRow In row1
int_row11 += 1
Dim rbl As RadioButtonList = CType(DataList1.Items(int_row11 - 1).FindControl("RadioButtonList2"), RadioButtonList) 这里运行时提示超出索引范围
If (rbl.SelectedValue = "") Then
Label12.Text = "单选题:" + int_row11Point.ToString() + "分"
Else
If (answer1("daan").ToString().Trim() = rbl.SelectedValue.ToString().Trim()) Then
int_row11Point += zhengshu2
Label12.Text = "单选题:" + int_row11Point.ToString() + "分"
Else
Label12.Text = "单选题:" + int_row11Point.ToString() + "分"
End If
End If
Next
[解决办法]
你监控一下,看DataList1.Items.Count是不是小于row1.Count?