DataList Problem

B

Byron

'm tryin to create a quiz management system for a skool project but i'm havin a problem automatically gradin. heres a screenshot for wats happening, wich is not wat shud hapen. as u can see its marking correct answers as wrong.

http://www.fiwizone.com/alex/byron/pics/project.jpg

heres the code 4 when u press finish.

Protected Sub finButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles finButton.Click

Dim right As Integer = 0, wrong As Integer = 0
For Each item As DataListItem In DataList1.Items
Dim dv As System.Data.DataView

Dim tfRadioButtonList As RadioButtonList = CType(item.FindControl("tfRadioButtonList"), RadioButtonList)

Dim QuestionIDHiddenField As HiddenField = CType(item.FindControl("QuestionIDHiddenField"), HiddenField)
Dim AnsHiddenField As HiddenField = CType(item.FindControl("AnsHiddenField"), HiddenField)
Dim wrongPanel As Panel = CType(item.FindControl("wrongPanel"), Panel)
Dim correctPanel As Panel = CType(item.FindControl("correctPanel"), Panel)

CType(item.FindControl("fbPanel"), Panel).Enabled = False
CType(item.FindControl("lsPanel"), Panel).Enabled = False
CType(item.FindControl("mcPanel"), Panel).Enabled = False
CType(item.FindControl("tfPanel"), Panel).Enabled = False

Select Case QuestionIDHiddenField.Value.ToString.Substring(0, 2)
Case "FB"

Case "MC"

Case "LS"

Case "TF"
Select Case tfRadioButtonList.SelectedValue.ToString = AnsHiddenField.Value.ToString
Case True
correctPanel.Visible = True
wrongPanel.Visible = False
right += 1
Case False
wrongLabel.Text = "Your Answer: " + tfRadioButtonList.SelectedValue.ToString + " Correct Answer: " + AnsHiddenField.Value.ToString
wrongPanel.Visible = True
correctPanel.Visible = False
wrong += 1
End Select
End Select
Next
summaryLabel.Text = "Right: " & right & ". " & "Wrong: " & wrong
summaryLabel.Visible = True
End Sub

__
Newsgroups brought to you courtesy of www.dotnetjohn.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top