I just started a project in MVC. I am new to MVC asp.net. I want to add a dropdown list box like I used to add in asp.net.
If you want to avoid the usage of model, you may simply use a ViewBag. in your action:
ViewBag.DirectorId = new SelectList(ListOfItemsToAdd, "dataValueField", "dataTextField", movie.DirectorId);
and in the view:
<%= Html.DropDownList("VariableNameToPost", ViewBag.DirectorId) //for asp.net view engine %>
@Html.DropDownList("VariableNameToPost", ViewBag.DirectorId) // for razor view engine
and the action that would accept the variable would then have something like this:
public ActionResult theAction(string VariableNameToPost){...}
refferences: