I have any Model
public class Account
{
[Key]
public int AccountID { get; set; }
public string UserName { get; set; }
public string Password { get; set; }
public string FullName { get; set; }
}
And
public class Role
{
[Key]
public int RoleID { get; set; }
public string RoleKey { get; set; }
public string RoleName { get; set; }
}
And
public class AccountRole
{
[Key]
public int ID { get; set; }
public int AccountID { get; set; }
public string Role { get; set; }
}
I want to use one view update Account and list role to list checkbox. When I checked in checkbox then role to insert in to AccountRole.
Please tell me how to create my View.
Create a holder for a Role + a boolean IsSelected
use this in your ViewModel as a List, pass it to your View and use it for display, when you submit your form you can check in your controller which roles are checked by looking in your ViewModel at the IsSelected boolean for each record in your SelectionRole List.