public IEnumerable <SelectListItem> AttendTypeData() { var qCV = new CodeValueModel().AttendTypesList().ToList(); qCV.Insert(0, new CodeValueItem { Id = 0, Code = "TY", Value = "(not specified)" }); // Can not use ToIdValueSelectList. This references TagValues. // This member function references attend types using AttendTypesList. // return ToIdValueSelectList(q); // Fixed a problem in which an empty value would select a selection // with an Id of 0. IEnumerable <SelectListItem> qSL; if (!IsEmptyValues(AttendTypeValues)) { qSL = from s in qCV select new SelectListItem { Value = $"{s.Id},{s.Value}", Text = s.Value, Selected = AttendTypeValues.Any(vv => vv.GetCsvToken().ToInt() == s.Id) }; } else { qSL = from s in qCV select new SelectListItem { Value = $"{s.Id},{s.Value}", Text = s.Value, Selected = false }; } return(qSL); }