views:

21

answers:

2

Hello,

I'm creating input radio dynamicly on a ASP.NET page using PlacHolders.

While reader.Read
Dim ltr As New Literal()
Dim ltr1 As New Literal()
Dim ltr2 As New Literal()
Dim ltr3 As New Literal()
Dim ltr4 As New Literal()
ltr.Text = reader.GetString(2) & "<br />"
PlaceHolder2.Controls.Add(ltr)
ltr1.Text = "<form> <input type = radio name=groupe" & i & " value=1>" & reader.GetString(3) & "<br />"
PlaceHolder2.Controls.Add(ltr1)
ltr2.Text = "<input type = radio name=groupe" & i & " value=1>" & reader.GetString(4) & "<br />"
PlaceHolder2.Controls.Add(ltr2)
ltr3.Text = "<input type = radio name=groupe" & i & " value=1>" & reader.GetString(5) & "<br />"
PlaceHolder2.Controls.Add(ltr3)
ltr4.Text = "<input type = radio name=groupe" & i & " value=1>" & reader.GetString(6) & "</form><br /><br />"
PlaceHolder2.Controls.Add(ltr4)
i = i + 1                   
End While

My problem is : how can I get all the items selected on those input radio.

A: 

I am not sure how'd you do it with your html form.

If dynamically create a RadioButton control instead of Literals, then you could check the RadioButton.Checked property to see if ti's true. Or you could use a RadioButtonList instead.

AaronLS
The problem is how can I know can I check the `Checked` property of all those `radio button`.
dotNET
When you generate the control, assign it a unique id, and then on postback call Page.FindControl and pass it the id, then cast it to a radiobutton and do `if(radioButton.Checked)` and do whatever it is you wanna do if it's checked. You could also loop through the controls, or if you used a RadioButtonList you only have on control to do it for and the Selected property give you the one chosen.
AaronLS
A: 

If you REALLY had to follow the implementation you have above, you could add an ASP.NET HiddenField control and use javascript to dump the value of the selected radio button into the hidden input.

Babak Naffas