Hi,
I am creating textbox, radiobuttonlist and checkboxlist dynamically
depending on data from a table. It is a questionnaire.
I add the control on a Panel control during the 1st load_page event.
Each question is displayed and answered, then result written to a SQL table.
Then the next question is read from a table and displayed using the
load_page event again.
The questions display and function perfectly. The user anwers the question
according to type (checkboxes,radiobuttons,textbox) and pressing a "Next"
button.
I then attempt to determine the type of question it was to process it
accordingly.
The following is a snippet of my code and the error message.
In load_page event:
Dim myROptions As RadioButtonList = New RadioButtonList
myROptions.Items.Add(CStr(MyReader("ChoiceText")))
Do While MyReader.Read 'read rest
myROptions.Items.Add(CStr(MyReader("ChoiceText")))
Loop
myROptions.ID = "myOpt"
pnlBoard.Controls.Add(myROptions)
Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.
From my Next button event:
Line 591: Dim dmyROpt As RadioButtonList
Line 592: dmyROpt = CType(pnlBoard.FindControl("myOpt"),
RadioButtonList)
Line 593: If myROptions.SelectedIndex > -1 Then
Line 594: DataChanged = True
Line 595: End If
What am I doing wrong? Please important deadline to meet....
txs,
--
Bill Jones