Reputation: 73938
I use this code to display a drop down menu list in my View, I would like to add a STATIC value at the beginning of the List with text like None and value as "". How to do it in Razor?
@Html.DropDownListFor(modal => modal.Candidates, new SelectList(Model.Candidates, "Value", "Key"))
Upvotes: 0
Views: 233
Reputation: 107277
There is an overload of DropDownListFor
which takes on a default string, e.g.
@Html.DropDownListFor(modal => modal.Candidates,
new SelectList(Model.Candidates, "Value", "Key"),
"None")
Upvotes: 3