Background: I have 4 dropdown lists on my page that all use one List of SelectListItem
to pull data from. All 4 of these dropdowns will always
Instead of using a List
, use a SelectList
. Then you can reuse the list of items in DropDownListFor
.
Model:
public SelectList PossibleItems { get; set; }
Controller:
var items = new List();
model.PossibleItems = new SelectList(items, "Value", "Text");
View:
@Html.DropDownListFor(m => m.Item1, Model.PossibleItems)
@Html.DropDownListFor(m => m.Item2, Model.PossibleItems)