MegaMatt
MegaMatt

Reputation: 23763

SQL/HTML: Put "Other" option to bottom of dropdown list

My site has a number of dropdown lists that require an option called "Other". Each dropdown has its own table to hold the values, and each of those tables has an entry called "Other" to be able to track the selection of that option.

The problem is that I am blanket sorting the options alphabetically when I retrieve them from the DB, but that puts the "Other" option somewhere in the middle of the list. I'd like it to always be at the bottom. Does anyone have a solution other than using an If check in the View to see if I'm printing "Other", then just tacking it onto the end?

I'm open to using the SQL query to put it at the bottom, or some other way on the server or view. Thanks.

EDIT: To answer the first couple questions, I'm using SQL Server 2005 and ASP.NET MVC 1. I don't mind tacking it onto the end, but it means If checks in something like 5 different places on my site. If I can find a way to sort it at the source (SQL) or something more scalable, that would be ideal.

Upvotes: 0

Views: 823

Answers (1)

spb
spb

Reputation: 987

In sql you could order it like this:

order by
case when value = 'Other' then 1 else 0 end,
value

Upvotes: 3

Related Questions