I have this
@Html.DropDownListFor(x => x.Names, new SelectList(Model.Names, "Value", "Text"), "---Filter By Name---", new { @class = "nameSelecter" })
When this renders “—Filter By Name—” will be the first choice. I am wondering can I set a value for this?
<option value="">---Filter By Name---</option>
Right now it has no value. I would like to give one.
The
DropDownListFordoesn’t support this. You will need to write a custom helper or do it with javascript. This being said setting a value for the default choice wouldn’t make sense as it will also break validation logic for required properties.