コード例 #1
0
        public static List <SelectListItem> ToSelectListItems(this IEnumerable <string> values, List <string> selectedValues = null, bool addDefault = false)
        {
            Check.Null(values, "values");

            var query = selectedValues == null || !selectedValues.Any() ? values.Select(x => DDLHelper.GetSelectListItem(x)) :
                        values.Select(x => DDLHelper.GetMarkedSelectListItem(x, selectedValues));

            return(addDefault ? query.ToDefaultPrependedList() : query.AsList());
        }
コード例 #2
0
        public static List <SelectListItem> ToSelectListItems(this IEnumerable <string> values, string selectedValue = null, bool addDefault = false)
        {
            Check.Null(values, "values");

            var query = string.IsNullOrWhiteSpace(selectedValue) ? values.Select(x => DDLHelper.GetSelectListItem(x)) :
                        values.Select(x => DDLHelper.GetMarkedSelectListItem(x, selectedValue));

            return(addDefault ? query.ToDefaultPrependedList() : query.AsList());
        }