It provides the user with a list of options out of which the user can select only one or multiple items at a time depending upon how the list box has been configured.
|Items||Represents the collection of items in the list box.|
|AutoPostBack||If True, the form is automatically posted when a new option is selected from the list box.|
|SelectedItem||Represents the selected option.|
|SelectedIndex||Specifies the index number of currently selected option.|
|SelectionMode||Determines whether a user can select more than one list item. Possible values are Single and Multiple.|
|Rows||Indicates the number of rows to display in the list box. Default is 4.|
|DataSource||Identifies the data source for the items listed in the list box.|
|DataMember||Identifies the particular table in a data source to bind to the control.|
|DataTextField||Identifies the field from the data source to use for option text.|
|DataValueField||Identifies the field from the data source to use for option values.|
|DataTextFormatString||Gets or sets a format string that determines how DataTextField is displayed.|
|DataBind||Binds the list box to a data source. Loads items from data source into the ListItemCollection collection.|
|OnSelectedIndexChanged||Raises the SelectedIndexChanged event.|
|SelectedIndexChanged||Raised when a new option is selected in the list box.|
You can add options in the list box in the same 3 ways as for other list control.
If you wish to enable the user to select more than one option at a time, set the SelectionMode property to the value Multiple. The user can use the Shift or Ctrl keys to select multiple options.
You can determine a single selected option by using either the SelectedIndex or the SelectedItem property. In case of multiple selections, these properties return information only for the first selected item. To determine all selected items, iterate through the ListItemCollection and check the Selected property of each item.