I have a problem with a dropdownlist. It's always empty,even though when debugging there is 4 different entries in the list that's set in asp-items as follows:
https://i.sstatic.net/pwreR.jpg
What am I doing wrong?
ViewModel:
public IEnumerable<SelectListItem> SelectRole { get; set; }
public string RoleId { get; set; }
Controller:
model.SelectRole = _roleManager.Roles?.Select(s => new SelectListItem
{
Value = s.Id,
Text = s.Name
});
View:
<select asp-for="RoleId" asp-items="@Model.SelectRole" class="form-control" />