Hello,
I want to know that How can we use Dropdown in Razor view MVC ?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Anupam SinghPosted Jun 19, 2014, 3:29 AM
Try this simple way:
In action:
ViewBag.Users = new SelectList(db.Users, "Name", "ID");//you can bind users from database .(EF)
in View:
@Html.DropDownList("Users", "")
However this is not professional way to achieve this. it breaks the MVC rules.
Hope will help.