There are always situations that we make good use of enums in projects. I like to use an Enum values to make my select list to save select-list-creation time. Here is what I always do,
Create an Enum, Eg. MonthFilter
public enum MonthFilter { [Description("Last Month")] LastMonth = 1, [Description("Last 3 Months")] Last3Months = 3, [Description("Last 6 Months")] Last6Months = 6, [Description("Last 12 Months")] Last12Months = 12, [Description("Year on Year")] YearOnYear = -1 }
And then create the SelectListItem using this Enum and its descriptions,
var monthFilters = from MonthFilter n in Enum.GetValues(typeof(MonthFilter)) select new SelectListItem { Value = ((int)n).ToString(), Text = Enumerations.GetEnumDescription(n) };
Last step is create the dropdown list, by passing in the “monthFilters” Select List Items,
@Html.DropDownList("MonthFilterDropDown", monthFilters, "Select...", null)