Andrew Stopford's Weblog






Old Blogs

ASP.NET Radiobutton group pain

Run into the bug that is detailed here today only with 2.0 datalists, has anyone else seen this?

Update: It seems others have run into this, see the comments for links to a workaround.
Posted: Sep 12 2006, 05:43 PM by astopford | with 6 comment(s)
Filed under:


William said:

Simply loop through the controls as in the javascript function and instead of setting each radiobuttons checked state, see if it is checked or not. If you hit a control with a checked state, that is the selected control.


if (re.test(


if (elm.checked)


// elm is the selected radiobutton.



# September 12, 2006 4:11 PM

AndrewSeven said:

Would it not be simpler to use an html control with runat=server in some sort of repeater (or build a control that does this) and take control of the html output rather than fiddle with the html's state on the client side?

# September 13, 2006 9:12 AM

mike said:

I'm talking about is determining which repeater item is selected on the server side. Client side doesnt really help me unless I can do some sort of callback in the method...

Possibilities for server side...

Loop through the controls in the repeater and look for a selected radio button. Determine the repeater item from there?

# September 13, 2006 10:30 AM

travis said:

I've tried the following to get the value server-side, but it doesn't seem to work for me:

If IsPostBack Then

For Each ri As RepeaterItem In Answers.Items

Dim AnswerButton As RadioButton

AnswerButton = CType(ri.FindControl("AnswerButton"), RadioButton)

If AnswerButton.Checked Then

Me.answer = ri.ItemIndex.ToString()

End If


End If

# December 5, 2006 11:40 AM

ra said:

Can i get solution for this problem. like which radiobutton is selected

# October 30, 2007 1:29 PM

rm said:

having same problem very frustrated.. yeah figured out the javascript thing, no biggie, only after 6 hours... BAH! so now its checking correctly, but when I findcontrol, the value always says unchecked??

# April 14, 2008 9:51 PM

vasumathi said:

thank you for your coding travis

# April 28, 2008 6:37 AM