public ActionResult RoleEdit(int RoleID) { var role = _repo.GetRoleByID(RoleID); RoleViewModel rvm = new RoleViewModel() { RoleID = role.RoleID, RoleName = role.RoleName.Trim(), RoleDescription = role.RoleDescription, IsSysAdmin = role.IsSysAdmin, assignedPermissions = role.Permissions.OrderBy(c => c.PermissionName).ToList() }; rvm.selectPermissions = new SelectList(_repo.GetPermissions(), "PermissionID", "PermissionName"); bool IsSaved; if (TempData["IsSaved"] != null) { IsSaved = (bool)TempData["IsSaved"]; ViewBag.IsSaved = IsSaved; } else { ViewBag.IsSaved = false; } return(View("RoleEdit", rvm)); }