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

ComboBox not sorting correctly

1 Answer 113 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Bill Holze
Top achievements
Rank 1
Bill Holze asked on 14 Jul 2011, 06:12 AM
I have a combobox that has numbers and alpha in the same list.  I need ALL to be the first choice but when I put ascending as a sort option the numbers are above the words.  Example below:

3rd Party
2 Board
ALL
Blade
Cards
Video

Is there a way to get ALL to the top so it looks like this. (See Below)  The choices are being filled from a datasource except for ALL which is being added by using the AppendDataBoundItems= True and Text = ALL
ALL
3rd Party
2 Board
Blade
Cards
Video

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 14 Jul 2011, 08:43 AM
Hello Bill,

Try the following code snippet in DataBound event to add default item in RadComboBox. Here is the sample code that I tried which worked as expected.

C#:
protected void RadComboBox1_DataBound(object sender, EventArgs e)
{
    var combo = (RadComboBox)sender;
    combo.Items.Insert(0, new RadComboBoxItem("All","All" ));
}

Also check the following help documentation which explains the same.
Insert a default item when databinding RadComboBox.

Thanks,
Princy.
Tags
ComboBox
Asked by
Bill Holze
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or