This is a migrated thread and some comments may be shown as answers.

RadComboBox Sorting

3 Answers 680 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Amit
Top achievements
Rank 1
Amit asked on 02 Nov 2010, 09:12 AM
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

3 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 02 Nov 2010, 09:51 AM
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.
0
Stephen
Top achievements
Rank 1
answered on 16 Oct 2013, 09:46 PM
Why do you have to bind to an event to sort a combo box? Is this really necessary when you have a  property?
0
Shinu
Top achievements
Rank 2
answered on 17 Oct 2013, 12:15 PM
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.
Tags
ComboBox
Asked by
Amit
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Stephen
Top achievements
Rank 1
Share this question
or