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
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