?
Solved

ASP.NET MVC dropdown list - OrderBy

Posted on 2016-07-20
2
Medium Priority
?
119 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

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Suggested Courses

743 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