sub show()
If pageindex = pagecount - 1 Then
Button3.Visible = True
End If
Dim pagesize As HttpCookie
Dim test As HttpCookie
Dim course As HttpCookie
pagesize = Request.Cookies("pagesize")
test = Request.Cookies("test")
course = Request.Cookies("course")
startindex = pageindex * pageitems j = startindex + 1
Dim a As Short Panel1.Controls.Clear()
Dim doc1 As dataoperation
Dim doc2 As dataoperation
strcon = "data source=JSJ246\SWFCCID;initial catalog=wk;persist security info=False;user id = sa;workstation id=JSJ246;packet size=4096"
doc1 = New dataoperation(strcon)
doc2 = New dataoperation(strcon)
Dim datatab As System.Data.DataTable
Dim datarows As System.Data.DataRow Dim datatime As DateTime = Now
datatab = doc1.executetable("select theme from temp_exam where test='" & test.Values("test") & "' and cast(starttime as datetime)<='" & datatime & "'and cast(endtime as datetime) >='" & datatime & "'")
For Each datarows In datatab.Rows
theme = Replace(datarows("theme"), "][", " or T_index=")
theme = Replace(theme, "[", "T_index=")
theme = Replace(theme, "]", "")
Dim datab As System.Data.DataTable
Dim datarow As System.Data.DataRow datab = doc2.executetable2("select question,option1,option2,option3,option4,option5,option6,ans ,t_value,t_index from " & course.Values("course") & " where " & theme & " order by t_index", startindex, pagesize.Values("pagesize"))
For Each datarow In datab.Rows j = j a = a
Dim lb As New label()
Dim li As New Literal()
li.Text = "<p>"
Panel1.Controls.Add(li) Dim lt As New Literal()
lt.Text = "<hr>"
Panel1.Controls.Add(lt) Panel1.Controls.Add(lb) Dim le As New Literal()
le.Text = "<hr>"
Panel1.Controls.Add(le) lb.ID = "label" & CStr(a)
lb.Text = CStr(j) & "." & "(" & "Rn:" & datarow("t_value") & ")" & datarow("question") Dim label(j) As label
label(j) = New label()
label(j).Text = datarow("t_index")
Panel1.Controls.Add(label(j))
label(j).Visible = False a = a + 1 Dim ans As String
Dim len As Short
ans = datarow("ans")
len = ans.Length If len > 1 Then
no = no
Dim i As Short
For i = 1 To 6
If datarow("option" & i) = "" Then
Else
Dim lit As New Literal() lit.Text = "<p>"
Panel1.Controls.Add(lit)
Dim lab(i) As label
lab(i) = New label()
Dim chose As String
Select Case i
Case 1
chose = "A."
Case 2
chose = "B."
Case 3
chose = "C."
Case 4
chose = "D."
Case 5
chose = "E."
Case 6
chose = "F."
End Select Panel1.Controls.Add(lab(i))
label(j).ID = "labl" & CStr(no)
lab(i).Text = chose & datarow("option" & i)
End If
Next Dim lite As New Literal()
lite.Text = "<p>"
Panel1.Controls.Add(lite)
Dim labl As New label()
labl.Text = "答案"
Panel1.Controls.Add(labl)
Dim txtbox As New TextBox()
txtbox.Height = New Unit(20)
txtbox.Width = New Unit(120)
txtbox.BorderStyle = BorderStyle.Solid
txtbox.BorderColor = Color.CornflowerBlue
txtbox.BackColor = Color.LightBlue
txtbox.BorderWidth = New Unit(1)
txtbox.ID = "txtbox" & CStr(no)
Panel1.Controls.Add(txtbox)
no = no + 1
j = j + 1
Else g = g + 1
Dim RadioBtnlist(j) As RadioButtonList
Dim ler As New Literal()
le.Text = "<hr>"
Panel1.Controls.Add(ler) RadioBtnlist(j) = New RadioButtonList()
RadioBtnlist(j).ID = "RadioBtnList" & CStr(j)
For h = 1 To 6 If datarow("option" & h) = "" Then 'datarow("option" & h) = CStr(0) Or
Else
Dim answer As String
Dim chose As String
RadioBtnlist(j).Items.Add(CStr(answer & h))
Select Case h
Case 1
chose = "A."
Case 2
chose = "B."
Case 3
chose = "C."
Case 4
chose = "D."
Case 5
chose = "E."
Case 6
chose = "F."
End Select
RadioBtnlist(j).Items(h - 1).Text = CStr(chose) & datarow("option" & h)
Panel1.Controls.Add(RadioBtnlist(j))
End If Next
RadioBtnlist(j).ID = "RadioBtnlist" & CStr(j)
label(j).ID = "lab" & CStr(g)
j = j + 1
End If Next Next
If pageindex = pagecount - 1 Then
Button3.Visible = True
End If
Dim pagesize As HttpCookie
Dim test As HttpCookie
Dim course As HttpCookie
pagesize = Request.Cookies("pagesize")
test = Request.Cookies("test")
course = Request.Cookies("course")
startindex = pageindex * pageitems j = startindex + 1
Dim a As Short Panel1.Controls.Clear()
Dim doc1 As dataoperation
Dim doc2 As dataoperation
strcon = "data source=JSJ246\SWFCCID;initial catalog=wk;persist security info=False;user id = sa;workstation id=JSJ246;packet size=4096"
doc1 = New dataoperation(strcon)
doc2 = New dataoperation(strcon)
Dim datatab As System.Data.DataTable
Dim datarows As System.Data.DataRow Dim datatime As DateTime = Now
datatab = doc1.executetable("select theme from temp_exam where test='" & test.Values("test") & "' and cast(starttime as datetime)<='" & datatime & "'and cast(endtime as datetime) >='" & datatime & "'")
For Each datarows In datatab.Rows
theme = Replace(datarows("theme"), "][", " or T_index=")
theme = Replace(theme, "[", "T_index=")
theme = Replace(theme, "]", "")
Dim datab As System.Data.DataTable
Dim datarow As System.Data.DataRow datab = doc2.executetable2("select question,option1,option2,option3,option4,option5,option6,ans ,t_value,t_index from " & course.Values("course") & " where " & theme & " order by t_index", startindex, pagesize.Values("pagesize"))
For Each datarow In datab.Rows j = j a = a
Dim lb As New label()
Dim li As New Literal()
li.Text = "<p>"
Panel1.Controls.Add(li) Dim lt As New Literal()
lt.Text = "<hr>"
Panel1.Controls.Add(lt) Panel1.Controls.Add(lb) Dim le As New Literal()
le.Text = "<hr>"
Panel1.Controls.Add(le) lb.ID = "label" & CStr(a)
lb.Text = CStr(j) & "." & "(" & "Rn:" & datarow("t_value") & ")" & datarow("question") Dim label(j) As label
label(j) = New label()
label(j).Text = datarow("t_index")
Panel1.Controls.Add(label(j))
label(j).Visible = False a = a + 1 Dim ans As String
Dim len As Short
ans = datarow("ans")
len = ans.Length If len > 1 Then
no = no
Dim i As Short
For i = 1 To 6
If datarow("option" & i) = "" Then
Else
Dim lit As New Literal() lit.Text = "<p>"
Panel1.Controls.Add(lit)
Dim lab(i) As label
lab(i) = New label()
Dim chose As String
Select Case i
Case 1
chose = "A."
Case 2
chose = "B."
Case 3
chose = "C."
Case 4
chose = "D."
Case 5
chose = "E."
Case 6
chose = "F."
End Select Panel1.Controls.Add(lab(i))
label(j).ID = "labl" & CStr(no)
lab(i).Text = chose & datarow("option" & i)
End If
Next Dim lite As New Literal()
lite.Text = "<p>"
Panel1.Controls.Add(lite)
Dim labl As New label()
labl.Text = "答案"
Panel1.Controls.Add(labl)
Dim txtbox As New TextBox()
txtbox.Height = New Unit(20)
txtbox.Width = New Unit(120)
txtbox.BorderStyle = BorderStyle.Solid
txtbox.BorderColor = Color.CornflowerBlue
txtbox.BackColor = Color.LightBlue
txtbox.BorderWidth = New Unit(1)
txtbox.ID = "txtbox" & CStr(no)
Panel1.Controls.Add(txtbox)
no = no + 1
j = j + 1
Else g = g + 1
Dim RadioBtnlist(j) As RadioButtonList
Dim ler As New Literal()
le.Text = "<hr>"
Panel1.Controls.Add(ler) RadioBtnlist(j) = New RadioButtonList()
RadioBtnlist(j).ID = "RadioBtnList" & CStr(j)
For h = 1 To 6 If datarow("option" & h) = "" Then 'datarow("option" & h) = CStr(0) Or
Else
Dim answer As String
Dim chose As String
RadioBtnlist(j).Items.Add(CStr(answer & h))
Select Case h
Case 1
chose = "A."
Case 2
chose = "B."
Case 3
chose = "C."
Case 4
chose = "D."
Case 5
chose = "E."
Case 6
chose = "F."
End Select
RadioBtnlist(j).Items(h - 1).Text = CStr(chose) & datarow("option" & h)
Panel1.Controls.Add(RadioBtnlist(j))
End If Next
RadioBtnlist(j).ID = "RadioBtnlist" & CStr(j)
label(j).ID = "lab" & CStr(g)
j = j + 1
End If Next Next
lab(i) = New label()
.....
Panel1.Controls.Add(lab(i))
如果我没记错的话,VB中象上面的语句该是声明数组的吧,怎么可以把一个控件数组加到Panel里去?
小妹现在好着急呀,求求各位给予指教。
代码中没有错误,在翻页时就会出现,但是在webform加载时不会出现异常。
小妹拜托了~~~~:(