I have a register model thats tighly bound to a register view. The register model has a selectlistitem poperty. Im having trouble populating a dropdownbox with the select list items.
var users = Roles.GetAllRoles();
model.UserRoles = users.Select(m => new SelectListItem()
{Value = m.ToString(),Text = m.ToString()})
@Html.DropDownListFor(r=>r.ToString(),Model.UserRoles,"Select Role")
You need to bind the selected value to a property of your model, like so:
(in your Model):
…
(in your View):