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

Sort a DDL by a third column

1 Answer 56 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
MArkB
Top achievements
Rank 1
MArkB asked on 16 Jul 2013, 06:16 PM
I have a RadComboBox that I need to sort by a column other than the Text or Value fields.

The Datasource and the control html is below.

An example subset of the values are:
ID    Rank    Sequence
8     E8     8
9     E9     9
10   O1    10
19   O10  19
11   O2     11

The column 'Sequence' is there to get it to sort in the right order because sorting on the key/ID and the Rank might not get it in the order the user is expecting it. In the case above, "O2" should follow "O1" and "O10" should follow "O9".

The example at: http://www.telerik.com/help/aspnet-ajax/combobox-how-to-implement-custom-sorting.html didn't seem to be what I needed.

    DefaultContainerName="PatientEntities" EnableFlattening="False"
        EntitySetName="Lookup_Rank"
          AutoPage="true" OrderBy="it.[Sequence]">
  </asp:EntityDataSource>

                <telerik:RadComboBox  ID="ddlRank" runat="server" Height="150px" Width="128px" AutoPostBack="true" OnDataBound="ddlRank_DataBound"
                     AllowReorder="false" DataSourceID="edsLookup_GetRanks" Sort="None"
                     DataTextField="Rank" DataValueField="Rank" ></telerik:RadComboBox>
                </td>

**Note: The forum editor was broken and wouldn't let me format as code.

1 Answer, 1 is accepted

Sort by
0
Nencho
Telerik team
answered on 19 Jul 2013, 11:22 AM
Hello Mark,

In the referenced article, it is demonstrated how to sort the items by Value, instead by Text. If you want to sort them, for example by their Attribute - Sequence, you could achieve that, by replacing the Value with the Item.Attributes["Sequence"] (in the Compare method).

Regards,
Nencho
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
DropDownList
Asked by
MArkB
Top achievements
Rank 1
Answers by
Nencho
Telerik team
Share this question
or