I'm working with ASP.net 3.5 and having a problem with adding an item to a List of a Structure in the ViewState.
I've declared the item to be added as New, but it complains when trying to insert into the viewstate object.
here's the code...
Code:Public Property QuestionsCorrect() As QuestionAnswer Get Return ViewState("QuestionsCorrect") End Get Set(ByVal value As QuestionAnswer) ViewState("QuestionsCorrect") = value End Set End PropertyHere's the class for all thatCode:Public Sub ProcessAnswers() Dim qA As New QABase Dim answerLetter As String = hidClickedAnswer.Value Select Case answerLetter Case "A" If ActiveQuestionAnswer = 0 Then qA.Correct = True Else qA.Correct = False End If Case "B" If ActiveQuestionAnswer = 1 Then qA.Correct = True Else qA.Correct = False End If Case "C" If ActiveQuestionAnswer = 2 Then qA.Correct = True Else qA.Correct = False End If Case "D" If ActiveQuestionAnswer = 3 Then qA.Correct = True Else qA.Correct = False End If Case "E" If ActiveQuestionAnswer = 4 Then qA.Correct = True Else qA.Correct = False End If End Select qA.QuestionId = ActiveQuestion QuestionsCorrect.QuestionList.Add(qA) If ActiveQuestion < 10 Then ActiveQuestion = ActiveQuestion + 1 End If End Sub
i've been working on this for sometime and can't figure it out...any help is greatly appreciatedCode:<Serializable()> _ Public Class QuestionAnswer Private _QuestionList As New List(Of QABase) Public Property QuestionList() As List(Of QABase) Get Return _QuestionList End Get Set(ByVal value As List(Of QABase)) _QuestionList = value End Set End Property End Class <Serializable()> _ Public Class QABase Private _QuestionId As Integer Private _Correct As Boolean Public Property QuestionId() Get Return _QuestionId End Get Set(ByVal value) _QuestionId = value End Set End Property Public Property Correct() Get Return _Correct End Get Set(ByVal value) _Correct = value End Set End Property End Class




Reply With Quote