Skip to main content
Tab

ASPxComboBox.SelectedIndex Property

Specifies the index of the selected item.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v24.1.dll

NuGet Package: DevExpress.Web

Declaration

[DefaultValue(-1)]
public int SelectedIndex { get; set; }

Property Value

Type Default Description
Int32 -1

The zero-based index of the selected item. -1 if no item is selected within the editor.

Remarks

The SelectedIndexChanged event fires when end users change the selection in the editor list or you change the SelectedItem or SelectedIndex properties.

<dx:ASPxComboBox ID="ASPxComboBox1" runat="server">
    <Items>
        <dx:ListEditItem Text="Afghanistan" Value="1" />
        <!--...-->         
    </Items>
</dx:ASPxComboBox>
protected void Page_Load(object sender, EventArgs e){
    ASPxComboBox1.SelectedIndex = 3;
}

If you bind (populate the Item collection) at runtime, make sure that you perform this operation during each round trip to the server in the control’s Init or Page_Init event. Otherwise, the SelectedIndex property may return -1.

protected void ASPxComboBoxInstance_Init(object sender, EventArgs e) {  
    DevExpress.Web.ASPxEditors.ASPxComboBox cmb = (DevExpress.Web.ASPxEditors.ASPxComboBox)sender;  
    cmb.DataSource = DATA_SOURCE;  
    cmb.DataBindItems();  
}  

For more information, refer to the following property description: EnableSynchronization

The following code snippets (auto-collected from DevExpress Examples) contain references to the SelectedIndex property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also