I'm adding the Roles provider to the built in AccountModel but having some problems adding GetAllRoles in my view using the Register View Model.
View Model from AccountModel
public class RegisterModel
{
UserName, Email Etc....
[Required]
[DisplayName("AllRoles")]
public SelectList AllRoles { get; set; }
}
Roles Service added to AccountModel
public interface IRolesService
{
SelectList GetAllRoles();
}
public class RolesService : IRolesService
{
public SelectList GetAllRoles()
{
var AllRoles = new SelectList(Roles.GetAllRoles());
return AllRoles;
}
}
Register View Page Inherits RegisterModel
Form...
<div class="editor-label">
<%= Html.LabelFor(m => m.ConfirmPassword) %>
</div>
<div class="editor-field">
<%= Html.PasswordFor(m => m.ConfirmPassword) %>
<%= Html.ValidationMessageFor(m => m.ConfirmPassword) %>
</div>
<%= Html.DropDownListFor(m => m.AllRoles)%>
I'm not sure how to populate the DropDown list with all the Roles from the View Model.
Any help would be really great!!