The RadioButtonList Web Control

The RadioButtonList control acts as a parent control for a collection of radio button list items. All child items of RadioButtonList are rendered by using a RadioButton control. A RadioButtonList control can have either no items or one item selected. The SelectedItem property returns the selected element as a ListItem object. However, you have no guarantee that only one item is selected at any given time. For this reason, be extremely careful when you access the SelectedItem property of a RadioButtonList control. Depending on the structure and flow of your code, the item returned could be a null object. A workaround that always shields you from unpleasant surprises is wrapping any call to Selected­Item in a

Get Building Web Solutions with ASP.NET and ADO.NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.