List<RoleInfo> roleInfoList = (List<RoleInfo>)ViewBag.AllRoles;错误原因很明确了ViewBag.AllRoles = RoleInfoService.LoadEntities(r=>r.DelFlag == DelFlag);改为ViewBag.AllRoles = RoleInfoService.LoadEntities(r=>r.DelFlag == DelFlag).ToList();