嘿我工作在線檢查表格,其中我創建了一個多選題的文件,所以這個創建的動態標籤和radiobuttonlist現在我試着檢查用戶選擇的答案是否正確或錯誤,所以爲此我創建了一個列表包含所有的單選按鈕列表和一個列表中的所有正確的答案,當用戶按下「提交」按鈕 - >如何從動態創建的單選按鈕列表中查找選定的單選按鈕?
dim answerList as List(Of String)
dim radionButtonList as List(Of RadioButtonList)
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
For i As Integer = 0 To radioButtonList.Count - 1
if String.Compare(radioButtonList(i).SelectedItem.ToString(), answerList(i)) <> 0 than
MsgBox("Wrong Answer")
End If
Next
End Sub
但是當我點擊該按鈕提供了一個錯誤「System.NullReferenceException:對象引用未設置到一個對象的實例「 我想頁面刷新時,我按下按鈕,所以任何想法我怎麼解決這個問題?