System.Web.UI.WebControls Namespace ListControl Class
Returns the selected item in a ListControl.
Script |
[ ListItem variable = ] ListControl.SelectedItem |
This property can only be used programmatically; it cannot be set when declaring the control.
variable |
A ListItem object that represents the first selected item in a ListControl. |
The property is read only with no default value.
Use the SelectedItem property to determine the currently selected list item in a single-selection ListControl. If the list control allows multiple selections, this property returns only the first selected item ( the item with the lowest index in the selection ).
Note that this property returns only the ListItem object itself. You must use either ListItem.Text and ListItem.Value to gain access to the specific list item property.
Below are links to code examples that illustrate using a list control's SelectedItem property in varied scenarios.
ListControl Members Items SelectedIndex SelectedValue