Sort a DDL by a third column

2 posts, 0 answers
  1. MArkB
    MArkB avatar
    7 posts
    Member since:
    Dec 2012

    Posted 16 Jul 2013 Link to this post

    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.
  2. Nencho
    Admin
    Nencho avatar
    1458 posts

    Posted 19 Jul 2013 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top