This documentation is archived and is not being maintained.

ListControl.SelectedIndex Property

Gets or sets the lowest ordinal index of the selected items in the list.

[Visual Basic]
Public Overridable Property SelectedIndex As Integer
[C#]
public virtual int SelectedIndex {get; set;}
[C++]
public: __property virtual int get_SelectedIndex();
public: __property virtual void set_SelectedIndex(int);
[JScript]
public function get SelectedIndex() : int;
public function set SelectedIndex(int);

Property Value

The lowest ordinal index of the selected items in the list. The default is -1, which indicates that nothing is selected.

Exceptions

Exception Type Condition
ArgumentOutOfRangeException The index was set to less than -1, or greater than or equal to the number of items on the list.

Remarks

Use this property to determine the index of the currently selected item in the list if the list control allows only one selection. If the list control supports multiple selections, use this property to determine the lowest index of the selected items.

Requirements

Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

See Also

ListControl Class | ListControl Members | System.Web.UI.WebControls Namespace | CheckBoxList

Show: