I have the following code:
int StatusID = ViewBag.DefaultStatus.StatusID;
List<NEOGOV_Ideas.Models.Status> statusList = ViewBag.StatusList;
@Html.DropDownList("DefaultStatus", new SelectList(statusList, "StatusID", "StatusName", StatusID))
but selected value does not set. Why?
Try like this in your controller action:
and in the view:
But I would recommend you using view models:
then in your controller action populate this view model and pass it to the view:
and finally in your strongly typed view: