fill the dropdown from enum

to fill dropdownlist from enum use the below code:

foreach (DropDownEnum enumValue in Enum.GetValues(typeof(DropDownEnum)))
{

model.SortOptions.Add(new SelectListItem()
{
Text = enumValue.ToString(),
Value = url+enumValue.ToString(),
Selected = false

});

}

Share the joy
  •  
  •  
  •  

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.