In ASP.NET MVC 2, I’d like to write a very simple dropdown list which gives static options. For example I’d like to provide choices between “Red”, “Blue”, and “Green”.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
See this MSDN article and an example usage here on Stack Overflow.
Let’s say that you have the following Linq/POCO class:
And let’s say that you have the following model:
And, finally, let’s say that you have the following list of colors. They could come from a Linq query, from a static list, etc.:
In your view, you can create a drop down list like so: