MVC3 model - how to make it so editorfor is a dropdown?

asp.net-mvc, asp.net-mvc-3, razor

Solution

Instead of `Html.EditorFor` you can use `Html.DropDownListFor`

@{
   var items = new SelectList(new[]
                   {
                       new SelectListItem {Text = "School1", Value = "School1"},
                       new SelectListItem {Text = "School2", Value = "School2"},
                   }, "Text", "Value");
}

@Html.DropDownListFor(x => x.school, @items)

Problem

I am making a MVC4 webapp for peers at 2 colleges to use, and later on I will expand to other schools. In my model I currently have ``` public string school { get; set; } ``` I would like it so when I do ``` @Html.EditorFor(model => model.school) ``` It would be a drop down of "school 1" and "School 2". How can I go about doing this cleanly? If I can, I would like to be able to make the change in the model and not have to do anything in the view besides call @Html.EditorFor. If the only way to accomplish this is do something in the view, that is OK as well.

Original source