I want to add a dropdownlist in my form, with 2 values userid and username in my dropdownlist, and also I want to get the value selected by the user when I click the button. I’m new to MVC and so far, I have not worked on dropdownlist, tried few samples but nothing seems to be working the way I want.
I want to add a dropdownlist in my form, with 2 values userid and
Share
I’ll jump lots of MVC3 concepts. If you’re really new to ASP.NET MVC, you should take a look at some tutorials.
This code should help you:
VIEW
ACTION
Please, note:
ACTION NAMEandCONTROLLER NAMEat theBeginFormhelper. You will have to modify this at your codeselectname (“select”) and the name of the argument at the action (“select”). This is not a coincidence, it’s a convention. MVC uses thenameattr to bind dataselectedattribute at the option will make it the default optionRegards