SelectionList.SelectedIndex Property

Definition

Returns the index of the selected item. The default value is -1. This API is obsolete. For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET.

[System.ComponentModel.Bindable(false)]
[System.ComponentModel.Browsable(false)]
public int SelectedIndex { get; set; }

Property Value

The index of the selected item.

Attributes

Exceptions

an attempt was made to set the SelectedIndex property to less than -1 or greater than or equal to the number of items.

Remarks

If the control is in multiple selection mode, this property returns the index of the first selected item. The selected index cannot be set declaratively; use the Selected property of a list item instead. Set the SelectedIndex to -1 to clear the selection. This is useful when you want to dynamically remove items from the list.

Applies to

Product Versions
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

See also