I want to update User Roles by using a select and post it to db. The select is working fine for RoleName but when I change or add a role, the RoleId has to be updated too. How do I do that in Razor pages?
With the below code only the RoleName is updated, for RoleId I get error because its valuue is null
- UserRoleClassName = await _context.Roles.Select(a => new SelectListItem
- {
- Value = a.Id.ToString(),
- Text = a.Name
- }).ToListAsync();
- class="col-3">
- ="RoleName">Role Name
- class="form-control" asp-for="AppIdentityRole.Role" asp-items="Model.UserRoleClassName">
- "RoleId" asp-for="AppIdentityRole.RoleId" class="form-control" value="@Model.UserRoleClassName" />

Marius VasilePosted Jun 12, 2020, 6:44 AM