急急!!!求助 程序第一次好用第二次以后就不好用了说索引超出范围 希望高手帮帮小弟
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
Response.Write("<script lanuage=javascript>alert('您确定要交卷吗?');localtion='shiti2.aspx';</script>")
Button2.Enabled = False
Dim connstr As String
connstr = ConfigurationManager.AppSettings("strconn").ToString
Dim conn As New SqlConnection(connstr)
Dim myadapter3 As SqlDataAdapter = New SqlDataAdapter("select * from tyx", conn)
Dim myds3 As DataSet = New DataSet()
myadapter3.Fill(myds3)
Dim row1() As DataRow = myds3.Tables(0).Select()
'计算单选题成绩
For Each answer1 As DataRow In row1
int_row1 += 1
Dim rbl As RadioButtonList = CType(DataList1.Items(int_row1 - 1).FindControl("RadioButtonList1"), RadioButtonList)提示这里说超出索引
If (rbl.SelectedValue = "") Then
Label15.Text = "单选题:0分"
Else
If (answer1("daan").ToString().Trim() = rbl.SelectedValue.ToString().Trim()) Then
int_row1Point += "select * from fts where f1=f1" '40 \ DataList1.Items.Count
Label15.Text = "单选题:" + int_row1Point.ToString() + "分"
End If
End If
Next
End Sub
[解决办法]
'计算单选题成绩
int_row1=0 '在这个地方加上这句代码
For Each answer1 As DataRow In row1
int_row1 += 1