public static SelectList ToSelectList <TEnum>(TEnum enumObj, bool useStringValue = false) { IEnumerable values = EnumExtension.ToList <TEnum>(useStringValue); Type enumType = EnumExtension.UnboxNullable <TEnum>(); var value = ""; if (enumObj != null) { var stringValue = enumObj.ToString(); if (useStringValue) { value = stringValue; } else { value = ((int)Enum.Parse(enumType, stringValue)).ToString(); } } return(new SelectList(values, "Value", "Text", value)); }
public static SelectList ToSelectList <TEnum>() { IEnumerable values = EnumExtension.ToList <TEnum>(); return(new SelectList(values, "Value", "Text")); }