Can I add Controls that are not ListItems to a RadioButtonList?

Posted by Simon Martin on Stack Overflow See other posts from Stack Overflow or by Simon Martin
Published on 2010-04-22T12:56:53Z Indexed on 2010/04/22 14:23 UTC
Read the original article Hit count: 223

Filed under:
|

I need to provide a way to allow users to select 1 Subject, but the subjects are grouped into Qualifications and so I want to show a heading for each 'group'. My first thought is an asp:RadioButtonList as that provides a list of options from which only one can be selected but there's no means to add break the list up with headings.

So I tried the following code - but I can't see that the LiteralControl is being added, which makes me think it's not a valid approach.

For Each item As Subject In Qualifications
        If item.QualCode <> previousQualCode Then
            rblSelection.Controls.Add(New LiteralControl(item.QualName))
        End If
        rblSelection.Items.Add(New ListItem(item.SubjectName, item.SelectionCode))
        previousQualCode = item.QualCode
    Next

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about radiobuttonlist