![]() ![]() | ||
Radio button list controls give you an easy way to display a single-selection radio button group. One useful aspect of this control is that lists of radio buttons can be generated at run time with data binding. As with checkbox controls, this control has an Items collection (inherited from the ListControl class) that holds the individual radio buttons in the list. Each item in the Items collection is an object of the ListItem class (see "Using the ListItem Class" in this chapter). You can use the ListItem class's Value, Text, and Selected properties to work with the individual radio buttons in the list, like this: RadioButtonList1.Items(5).Selected. To determine which item is selected, you can test the SelectedItem property of the list. You don't need to loop over each item (although, like each item in checkbox lists, each item also has a Selected property). You also can find the selected item's index with the SelectedIndex property.
And, as with checkbox lists, you can specify the way the list is actually displayed by using the RepeatLayout and RepeatDirection properties (see the In Depth section "Checkbox Lists" for the details).
![]() ![]() | ||