RadComboBox Sorting

4 posts, 1 answers
  1. Amit
    Amit avatar
    88 posts
    Member since:
    Sep 2010

    Posted 02 Nov 2010 Link to this post

    hey everyone

    I have a RadComboBox in which i want items to sort in ascending order.this is my combobox--
    <telerik:RadComboBox ID="cmbName" runat="server" Skin="Hay" DataSourceID="SqlDataSource1"
                                    Height="60px" Width="204px" DataTextField="CustomerName" MarkFirstMatch="true"
                                    DataValueField="CustomerId" AllowCustomText="true" EmptyMessage="Please select a Name"
                                    OnSelectedIndexChanged="cmbName_SelectedIndexChanged" AutoPostBack="true" ToolTip="Select your Name"
                                    CausesValidation="false" Sort="Ascending" SortCaseSensitive="true">
                                </telerik:RadComboBox>
    But its not working,items does'nt get sorted.It comes as it is in data base table.Does this need something to be written in codebehind too?...

    Thanks
    Amit
  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 02 Nov 2010 Link to this post

    Hello Amit,


    Call the SortItems() method of the combobox or Items.Sort() method of the items collection.
    protected void RadComboBox1_DataBound(object sender, EventArgs e)
    {       
       RadComboBox1.Items.Sort();
    }


    For more information:
    Sorting


    -Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Stephen
    Stephen avatar
    1 posts
    Member since:
    Jun 2013

    Posted 16 Oct 2013 Link to this post

    Why do you have to bind to an event to sort a combo box? Is this really necessary when you have a  property?
  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 17 Oct 2013 Link to this post

    Hi Stephen,

    Setting the sort property alone wont help. To enable sorting you need to:

    1. Set the Sort property. Its value can be either Ascending, Descending or None.
    2. Call the SortItems() method of the RadComboBox or Items.Sort() method of the items collection.

    Thanks,
    Shinu.
Back to Top