Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // ViewModel Classes
- public class UserFormViewModel
- {
- // properties
- public User User { get; private set; }
- public SelectList Roles { get; private set; }
- // Constructor
- public UserFormViewModel(User user)
- {
- User = user;
- Roles = new SelectList(Roles.All, ); //this is where I have problems
- }
- }
- <ul>
- <% foreach (var role in Roles as IEnumerable<SelectListItem>)) { %>
- <li><%= Html.CheckBox(role.ToString())%> <%= role.ToString() %></li>
- <% } %>
- </ul>
- <li><%= Html.CheckBox(role.ToString(),
- Roles.IsUserInRole(Model.User.Identity.LoginName, role.ToString())) %>
- <%= role.ToString() %>
- </li>
- <ul>
- <%
- string[] allroles = Roles.GetAllRoles();
- foreach (string role in allroles) {
- %>
- <li>
- <%= Html.CheckBox(role.ToString(), Roles.IsUserInRole(Model.UserName, role.ToString())) %>
- <%= role.ToString() %>
- </li>
- <% } %>
- </ul>
Add Comment
Please, Sign In to add comment