
[英]ASP.NET MVC3 How to use roles to hide delete links from non-admin users?
[英]How to use checklistbox to update roles in account in mvc3
我有模特
public class Account
{
[Key]
public int AccountID { get; set; }
public string UserName { get; set; }
public string Password { get; set; }
public string FullName { get; set; }
}
和
public class Role
{
[Key]
public int RoleID { get; set; }
public string RoleKey { get; set; }
public string RoleName { get; set; }
}
和
public class AccountRole
{
[Key]
public int ID { get; set; }
public int AccountID { get; set; }
public string Role { get; set; }
}
我想使用一个视图更新“帐户和列表角色来列出”复选框。 当我选中复选框时,要插入到AccountRole中的角色。
请告诉我如何创建我的视图。
为角色+布尔IsSelected创建一个持有人
public class SelectionRoles
{
public bool IsSelected { get; set;}
public Role OneRole { get; set; }
}
在ViewModel中以列表的形式使用它,将其传递给View并用于显示,当您提交表单时,可以通过在ViewModel中的IsSelected布尔值中查看SelectionRole中的每个记录,来检查控制器中哪些角色已被检查清单。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.