asp.net.ph

ListControl.SelectedItem Property

System.Web.UI.WebControls Namespace   ListControl Class


Returns the selected item in a ListControl.

Syntax


Script [ ListItem variable = ] ListControl.SelectedItem

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

Property Value


variable A ListItem object that represents the first selected item in a ListControl.

The property is read only with no default value.

Remarks

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.

Example

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

Populating a List Control from a Database
Run Sample | View Source
Using a DropDownList in an Editable DataList
Run Sample | View Source
GridView RowCreated, RowDataBound Events Example
Run Sample | View Source
See Also

ListControl Members   Items   SelectedIndex   SelectedValue 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