<asp:ListItem Text="Green" value="green" />
</asp:DropDownList>
The most useful event that this control provides is SelectedIndexChanged. This
event is exposed by other list controls, such as the CheckBoxList and
RadioButtonList controls, allowing for easy programmatic interaction with the
control. These controls can also be bound to a database, allowing you to extract
dynamic content into a drop-down menu.
ListBox
A ListBox control equates to the HTML select element with either the multiple
or size attribute set (size would need to be set to a value of 2 or more). If you
set the SelectionMode attribute to Multiple, the user will be able to select more
than one item from the list, as in this example:
<asp:ListBox id="listTechnologies" runat="server"
SelectionMode="Multiple">
<asp:ListItem Text="ASP.NET" Value="aspnet" />
<asp:ListItem Text="JSP" Value="jsp" />
<asp:ListItem Text="PHP" Value="php" />
<asp:ListItem Text="CGI" Value="cgi" />
<asp:ListItem Text="ColdFusion" Value="cf" />
</asp:ListBox>
RadioButtonList
Like the RadioButton control, the RadioButtonList control represents radio
buttons. However, the RadioButtonList control represents a list of radio buttons
and uses more compact syntax. Here’s an example:
<asp:RadioButtonList id="favoriteColor" runat="server">
<asp:ListItem Text="Red" Value="red" />
<asp:ListItem Text="Blue" Value="blue" />
<asp:ListItem Text="Green" Value="green" />
</asp:RadioButtonList>
CheckBoxList
As you may have guessed, the CheckBoxList control represents a group of check
boxes; it’s equivalent to using several CheckBox controls in row:
<asp:CheckBoxList id="favoriteFood" runat="server">
<asp:ListItem Text="Pizza" Value="pizza" />
111
List Controls