Skip to main content
A newer version of this page is available. .
Tab

ASPxListEdit.SelectedIndex Property

Gets or sets the selected list item’s index.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v19.1.dll

Declaration

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

Property Value

Type Default Description
Int32 -1

An integer value, representing the zero-based index of the selected list item.

Remarks

Use the SelectedIndex property to move selection within the list editor. The default value specifies that no item is selected within the list editor. You can also change the selected item via the ASPxListEdit.SelectedItem property.

Handle the ASPxListEdit.SelectedIndexChanged event to respond to the selection being changed within the list editor.

Example

This example demonstrates how the ASPxSpinEdit‘s decimal separator is automatically changed upon selecting a culture.

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register assembly="DevExpress.Web.v8.3, Version=8.3.2.0, Culture=neutral, 
PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxEditors" tagprefix="dxe" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
     protected void Page_Load(object sender, EventArgs e) {
         ASPxRadioButtonList1.SelectedIndex = GetCulture() == "en-US" ? 0 : 1;
     }
     protected override void InitializeCulture() {
         base.InitializeCulture();
         CultureInfo ci = new CultureInfo(GetCulture(), true);
         System.Threading.Thread.CurrentThread.CurrentCulture = ci;
         System.Threading.Thread.CurrentThread.CurrentUICulture = ci;
     }
     private string GetCulture() {
         string culture = "en-US";
         if (!string.IsNullOrEmpty(Page.Request.Params["culture"]))
             culture = Page.Request.Params["culture"];
         int comma = culture.IndexOf(",");
         if (comma != -1)
             culture = culture.Remove(comma);
         return culture;
     }
</script>

 <html xmlns="http://www.w3.org/1999/xhtml" >
 <head id="Head1" runat="server">
     <title>Support for Different Cultures</title>
 </head>
 <body>
     <form id="form1" runat="server">
     <div>
         <br/>
         <asp:Label ID="Label1" runat="server" Text="Culture: " 
         AssociatedControlID="ASPxRadioButtonList1"/>
         <dxe:ASPxRadioButtonList ID="ASPxRadioButtonList1" runat="server" SelectedIndex="0">
             <Items>
                 <dxe:ListEditItem Text="English (USA)" Value="en-US" />
                 <dxe:ListEditItem Text="Italian" Value="it-IT" />
             </Items>
             <ClientSideEvents SelectedIndexChanged="function(s, e) {
     document.location.href = "?culture=" + s.GetSelectedItem().value;
 }" />
         </dxe:ASPxRadioButtonList>
         <br/><br/>
         <dxe:ASPxSpinEdit ID="ASPxSpinEdit1" runat="server" Number="0.1" />
     </div>
     </form>
 </body>
 </html>

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