I am new to MVC and have been told not to use SelectListItem in the View as its untidy. I was advised to put it in the Model and then pass to the view.
I have no idea whether my code in the Model is correct. Any assistance would be highly appreciated. Code is here:
public class ZipCodeModel
{
public string ZipCode { get; set; }
public static readonly
IEnumerable<SelectListItem> items;
static ZipCodeModel()
{
items = new List<SelectListItem>
{
new SelectListItem {Text = "A"},
new SelectListItem {Text = "B"},
new SelectListItem {Text = "C"},
new SelectListItem {Text = "D"}
};
}
}
Thanks in advance :)