ASP.NET Radiobutton group pain

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

Update: It seems others have run into this, see the comments for links to a workaround.

7 Comments

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

    i.e.:
    if (re.test(elm.name))
    {
    if (elm.checked)
    {
    // elm is the selected radiobutton.
    }
    }

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

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

  • 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
    Next
    End If

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

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

  • thank you for your coding travis

Comments have been disabled for this content.