Load (Populate) DropDownList from Controller in ASP.Net MVC

Last Reply one year ago By bigbear

Posted one year ago

Hello everyone

How to load Dropdownlist value in select from controller where value and text are different.

i am just simply trying to load values in a dropdownlist from a controller.

if I have both the value and text be the same values it works with the model property.

But i am trying to have the value be the id and the text to be the name with this setup the dropdown is not loading the id.

If both text and value are the same I can just do this and it works

@Html.DropDownListFor(e => e.ServiceVM.Employee, Model.Employees, "Select Employee", new { @class = "form-control" })


vm.Employee = new SelectListItem { Value = model.EmployeeID.ToString(), Selected=true };
This question does not have replies that have been liked.