Hello,
I want to know that How can we use Dropdown in Razor view MVC ?
Dropdown in razor view mvc
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Anupam SinghRank #643 · 3.7K reputationPosted Jun 18, 2014, 11:29 PM EDT
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.