Dynamic RadioButtonList problem

H

Hugo Flores

Hi,
Here's the situation:

I create a table on run time(Page_Init)
I add a textbox to the first row
I add a RadioButtonList in that same row

The problem is that when I try to get the values that the user selected
from the RadioButtonList I always end up getting the first item
selected. At first my code had the first item selected by default, so I
thought it was just that, because on post back I recreate the whole
thing on the Page_Init, but then I just commented that line, and I
still get the first item selected.

Here's my code:

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
BindTable()
End Sub

Private Sub BindTable()
Dim tr As TableRow
Dim td As TableCell
Dim txtText As New TextBox
Dim rdoYesNo As New RadioButtonList

tr = New TableRow
td = New TableCell
td.Controls.Add(txtText)

rdoYesNo.Items.Add(New ListItem("No", "0"))
rdoYesNo.Items.Add(New ListItem("Yes", "0"))
'rdoYesNo.Items(0).Selected = True
td.Controls.Add(rdoYesNo)

tr.Cells.Add(td)

Table1.Rows.Add(tr)

End Sub

I would also like to know if I can still have the first option selected
on my first call to the page.

Thanks
 

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,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top