DropdownListFor default value

So, I did something like this:

@Html.DropDownListFor(model => model.Dessert, 
                      new SelectList(Model.AvailableDesserts, "DessertID", "DessertName"),
                      "---Select A Dessert ---")

Seems to work pretty well. Dessert in my viewmodel is the one selected by the user. AvailableDesserts is a collection of ones to pick from. Hope that helps.

Leave a Comment