I am creating a form to post edits back to the controller and have a few drop downs in the controller. I have tried two different ways that are not working in the view. This is what I tried first:
@Html.DropDownList("TechnicianId", null, htmlAttributes: new { @class = "form-control" })
Now I am trying this:
@Html.DropDownListFor(m => m.TechnicianId, ViewBag.TechnicianId)
and this:
@Html.DropDownListFor(m => m.TechnicianId, TechnicianId)
from what I look online the second or third one are the closest. However it is not coming up as a list. Here is the code I have in the controller:
ViewBag.TechnicianId = new SelectList(db.Users.Where(u => u.Status == 1 || u.RoleID == new Guid("00000000-0000-0000-0000-000000000000")), "UserId", "FullName");
The expression in DropDownListFor should identify the object that contains the properties to display.
Try having users in the TechnicianId list:
And then in the view: