[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

ASP.NET MVC dropdown list - OrderBy

Posted on 2016-07-20
2
Medium Priority
?
144 Views
Last Modified: 2016-07-20
Hi Experts,
This code shows a dropdown list on my webpage, but it orders it by ID, not by Code, as I would like it to do it.

@Html.DropDownList("DelayCodesDDL", null, new { style = "background-color:#ffecb0; width:60px;" })

How could I make it order it by Code ascending? The table from where the dropdown list is populated hast two columns: ID, and Code.

Thank you for your help.
0
Comment
Question by:romsom
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 18

Accepted Solution

by:
Anil Golamari earned 2000 total points
ID: 41721434
If you want to sort the dropdown list by value and not by the key of the element then you can use linq to first sort the data source and then you can assign it to dropdown.

Check this link
1
 

Author Closing Comment

by:romsom
ID: 41721960
The link was very useful; I managed to fix the problem.
Thank you very much!
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question