System.Web.UI.WebControls Namespace ListControl Class
Returns the value of the selected item in a ListControl, or selects the item in a list control that contains the specified value.
Script |
[ string variable = ] ListControl.SelectedValue |
This property can only be used programmatically; it cannot be set when declaring the control.
variable |
A string representing the value of the selected item in a ListControl. |
The property is read/write with no default value.
Use the SelectedValue property to determine the value of the selected item in a ListControl. This property returns the Value property of the selected ListItem.
If the list control allows multiple selections, this property returns only the value of the first selected item ( the item with the lowest index in the selection ). If no item is selected, an empty string ( "" ) is returned.
The SelectedValue property can also be used to select an item in the list control by setting it with the value of the item. If no items in the list control contain the specified value, an ArgumentOutOfRangeException is thrown.
Below are links to code examples that illustrate using a list control's SelectedValue property in varied scenarios.
ListControl Members Items SelectedIndex SelectedItem