System.Web.UI.WebControls Namespace
Renders a list box that allows single or multiple item selection.
Visibility |
Constructor |
Parameters |
public |
ListBox |
( )
|
|
Use the ListBox control to create a list control that allows single or multiple item selection.
Like all controls that derive from the ListControl base class, the ListBox can display content declared at design time, or dynamically bound from a data source at run time.
To specify the items you want to appear in the control, declare a ListItem object for each entry, between the opening and closing tags of the control.
To bind the control to a data source, create or specify the source, then use the DataBind method ( inherited from the base Control class ) to populate the contents of the control.
You can use any supported enumerable collection of data, such as those from datareaders, datasets, datatables, dataviews, arraylists, and so on.
The ListBox includes a SelectionMode property, which you use to specify or determine if the list control allows multiple item selection.
NOTE: Certain properties inherited from the base WebControl class are not applicable to the ListBox. These include the BorderColor, BorderStyle, BorderWidth and ToolTip properties.
For examples illustrating use of this control, see the individual member types of this class. For syntax information, see ListBox in ASP.NET Syntax for Web Controls.
DropDownListBox, ListControl, ListItem