ASP.NET ListBox Control

Definition and Usage

The ListBox control is used to create a dropdown list that allows single selection and multiple selection.

The optional items in the ListBox control are defined by the ListItem element!

Tip:This control supports data binding!

Property

Property Description .NET
Rows The number of rows displayed in the list. 1.0
SelectionMode Allow single selection or multiple selection. 1.0

Web Control Standard Attributes

AccessKey, Attributes, BackColor, BorderColor, BorderStyle, BorderWidth 
CssClass, Enabled, Font, EnableTheming, ForeColor, Height, IsEnabled 
SkinID, Style, TabIndex, ToolTip, Width

For a complete description, please visit Web Control Standard Attributes.

Control Standard Attributes

AppRelativeTemplateSourceDirectory, BindingContainer, ClientID, Controls 
EnableTheming, EnableViewState, ID, NamingContainer, Page, Parent, Site 
TemplateControl, TemplateSourceDirectory, UniqueID, Visible

For a complete description, please visitControl Standard Attributes.

Example

Listbox
In this example, we declare a ListBox control in the .aspx file. Then we create an event handler that displays text and the selected item in the Label control when a Click event occurs.