I try to convert Enum to SelectListItem. I can get the text but I can't get the value itself.
here is my attempt.
// A method to convert Enum to SelectListItem
public static IEnumerable<SelectListItem> GetEnumSelectList<T>()
{
return (Enum.GetValues(typeof(T)).Cast<T>().Select(
enu => new SelectListItem() { Text = enu.ToString(), Value = enu.ToString() })).ToList();
}
this method returns Text = enu.ToString(), Value = enu.ToString()
returning Text is fine but it is the same with Value.
I don't know how to retrieve values of the enum so I can get 0,1 instead of Import or Export