public ActionResult ChangeGroup(int id = 0) { var daoUser = new UserDao(); var daoUserGroup = new UserGroupDao(); var user = daoUser.ViewDetail(id); List <string> result = new List <string>(); if (user.GroupID != null) { result = user.GroupID.Split(',').ToList(); } var lstUserGroupFirst = daoUserGroup.GetUserGroup(); Dictionary <string, string> lstGroupId = new Dictionary <string, string>(); foreach (var item in result) { lstGroupId.Add(item, item); } TempData["lstGroupId"] = result; foreach (var role in result) { foreach (var item in lstUserGroupFirst.ToList()) { if (role.Trim() == item.ID.Trim()) { lstUserGroupFirst.Remove(item); } } } // show data có thể dùng ajax TempData["lstUserGroupFirst"] = lstUserGroupFirst; return(View(user)); }