I have a problem with HTML.DropDownList, I´m unable to set Selected item in Edit view. I found many simmilar topics, but no one helps me find a resolution.
I will get SelectList from ViewBag:
SelectList sl = new SelectList(ViewBag.EmployeesTest, "Id", "DisplayName", 9908);
In View I will use
Html.DropDownList("employee",sl, new { @class = "form-control" })
In VS Debuger I can see list with all employees and employee with ID have property selected = true
, but this employee is not set as selected in generated <select>
input.
Do you have any what can be wrong?
Thanks
Alex.