Can I add Controls that are not ListItems to a RadioButtonList?
- by Simon Martin
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