I want to add the "selected" property to one of the options
in the drop down list based on the value to the option
@Html.DropDownListFor(m => m.OvelseTypeId, new SelectList(Model.OvelseType, "Id", "navn"), "-- Please select --", new { @class = "form-control" })
I would image it to be something like (8 being the value)
@Html.DropDownListFor(m => m.OvelseTypeId, new SelectList(Model.OvelseType, "Id", "navn").Select(8), new { @class = "form-control" })
or
@Html.DropDownListFor(m => m.OvelseTypeId, new SelectList(Model.OvelseType, "Id", "navn"), 8, new { @class = "form-control" })
I have seen Html.DropDownListFor set selected value. But I just feel there has to be an easier way, as I simply just want to add selected
to one of the options in the drop down list. Giving me