Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 370479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T14:01:19+00:00 2026-05-12T14:01:19+00:00

I have dropdown list as follow: <select id=DropdownID> <option value=1>Ccc</option> <option value=2>Aaa</option> <option value=3>Bbb</option>

  • 0

I have dropdown list as follow:

<select id="DropdownID">
    <option value="1">Ccc</option>
    <option value="2">Aaa</option>
    <option value="3">Bbb</option>
</select>

but i want dropdown elements sorted by text not value, in alphabetical order:

<select id="DropdownID">
    <option value="2">Aaa</option>
    <option value="3">Bbb</option>
    <option value="1">Ccc</option>        
</select>

I fill it on this way:

Dictionary<int, string> myDataDictionary = new Dictionary<int, string>();

// (...)

DropdownID.DataSource = myDataDictionary;
DropdownID.DataTextField = "value";
DropdownID.DataValueField = "key";
DropdownID.DataBind();

Even if values in dictionary are sorted correctly, in dropdown they are always ordered by value.

How to sort items in dropdow by text rather than by value ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T14:01:19+00:00Added an answer on May 12, 2026 at 2:01 pm
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:DropDownList ID="DropdownID" runat="server">
            </asp:DropDownList>
        </div>
        </form>
    </body>
    </html>
    
    Dictionary<int, string> myDataDictionary = new Dictionary<int, string>();
    
            myDataDictionary.Add(3, "A");
            myDataDictionary.Add(1, "B");
            myDataDictionary.Add(2, "C");
    
            DropdownID.DataSource = myDataDictionary;
            DropdownID.DataTextField = "value";
            DropdownID.DataValueField = "key";
            DropdownID.DataBind();
    

    Hi there I have this working sample, what ever I do with the dictionary the drop down is ordered correctly.

    could you post your working sample so we could reproduce your error plz.

    Edit: 13:21 22/09/2009

    What ever order you put your data in is the order that the dropdown list will use to display the collection. I think there must be something else that you are not aware off. The best way to find out if it is a problem with your code or something is truly amiss is to write a test app get something simple from scratch try to reproduce the behaviour of the original app.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have a drop-down list like: <select id='list'> <option value='1'>Option A</option> <option value='2'>Option
I have a dropdown list that stores name/value pairs. The dropdown appears in each
I have a dropdown list of items a user can select from (the view
I have dropdown list control in one of my application and when I add
So, I have an autocomplete dropdown with a list of townships. Initially I just
I have the following dropdown box <form name=myform method=POST ACTION=songs.php> Select Category: <select id=sel
I have a drop-down list with known values. What I'm trying to do is
Does anyone know how many options a drop down list can have? Is it
I'd like to add a drop-down list to a Windows application. It will have
I have a dropdownlist with the autopostback set to true. I want the user

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.