asp.net.ph

ListControl.SelectedValue Property

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.

Syntax


Script [ string variable = ] ListControl.SelectedValue

This property can only be used programmatically; it cannot be set when declaring the control.

Property Value


variable A string representing the value of the selected item in a ListControl.

The property is read/write with no default value.

Remarks

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.

Example

Below are links to code examples that illustrate using a list control's SelectedValue property in varied scenarios.

Dynamically Setting and Retrieving the Font Properties of a Web Control
Run Sample | View Source
DetailsView with Default Paging
Run Sample | View Source
GridView ImageField Example
Run Sample | View Source
See Also

ListControl Members   Items   SelectedIndex   SelectedItem Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph