I have managed to solve my problem but that lead to asecond problem.
My new code is as follows:
Sub CreateRadioButtons(ByVal dr)
' Instantiate RadioButtonList
Dim RadioButtonListProfiles As New RadioButtonList
'Add radiobuttonlist into a placeholder
PlaceHolderProfiles.Controls.Add(RadioButtonListPr ofiles)
Do While dr.Read()
RadioButtonListProfiles.Items.Add(New ListItem(dr("PRO_en")))
Loop
End Sub
However I would now like to change the code on the HTML page so it can
access the radiobuttonlist via the control. Before, the code on the HTML
page was as foolows:
Sub chkLayout_CheckedChanged(sender As Object, e As EventArgs)
If chkLayout.Checked = True Then RadioButtonListProfiles.RepeatLayout =
RepeatLayout.Table
Else RadioButtonListProfiles.RepeatLayout = RepeatLayout.Flow
End If
End Sub
and it worked very well. How do I now reference the propetries of the
RadioButtonList through the PlaceHolderProfiles?
Thank you
"Tapi" <t.******@free.fr> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Hello there,
I am new to ASP .NET and am tryimg to create a RadioButtonList
dynamically. My code below gives an "Index was out of range" error.
Where am I going wrong?
Sub CreateRadioButtons(ByVal dr)
' Instantiate RadioButtonList
Dim DynamicRadioButtonList As New RadioButtonList
Dim t As Integer
t = 0
Do While dr.Read()
DynamicRadioButtonList.Items(t).Text = dr("PRO_en")
t = t + 1
Loop
'Add radio button
PlaceHolderGroup.Controls.Add(DynamicRadioButtonLi st)
End Sub
Thank you for your help