Asp.net mvc 3 如何使用复选框更新mvc3中帐户中的角色
我有模型吗Asp.net mvc 3 如何使用复选框更新mvc3中帐户中的角色,asp.net-mvc-3,checkboxlist,checklistbox,Asp.net Mvc 3,Checkboxlist,Checklistbox,我有模型吗 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 Account
{
[Key]
public int AccountID { get; set; }
public string UserName { get; set; }
public string Password { get; set; }
public string FullName { get; set; }
}
及
及
我想使用一个视图更新帐户和列表角色来列出复选框。当我签入复选框时,然后将要插入的角色插入AccountRole
请告诉我如何创建我的视图。为一个角色创建一个持有者+一个布尔值
public class SelectionRoles
{
public bool IsSelected { get; set;}
public Role OneRole { get; set; }
}
在ViewModel中将其用作列表,将其传递给视图并用于显示,提交表单时,您可以通过查看ViewModel中SelectionRole列表中每个记录的IsSelected布尔值,在控制器中检查要检查的角色
public class AccountRole
{
[Key]
public int ID { get; set; }
public int AccountID { get; set; }
public string Role { get; set; }
}
public class SelectionRoles
{
public bool IsSelected { get; set;}
public Role OneRole { get; set; }
}