SelectedIndex Property

DropDownList::SelectedIndex Property

 

Gets or sets the index of the selected item in the DropDownList control.

Namespace:   System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

public:
property int SelectedIndex {
	virtual int get() override;
	virtual void set(int value) override;
}

Property Value

Type: System::Int32

The index of the selected item in the DropDownList control. The default value is 0, which selects the first item in the list.

Use the SelectedIndex property to programmatically specify or determine the index of the selected item from the DropDownList control. An item is always selected in the DropDownList control. You cannot clear the selection from every item in the list at the same time.

System_CAPS_noteNote

The indexes for the items in the DropDownList control are zero-based.

The following code example demonstrates how to use the SelectedIndex property to determine the selected item in the DropDownList control.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 1.1
Return to top
Show:
© 2016 Microsoft