I've the following code for a DropDownListFor and is working ok
@Html.DropDownListFor(Function(model) model.Habilitacoes, New SelectList(ViewBag.Habilitacoes, "KeyHL", "DescricaoHL"), New With {.class = "FillHSpace"})
The ViewBag.Habilitacoes is a List(Of T)
But know I want to add the SelectedValue to the DropDownListFor, so I've used the following code but doesn't work.
@Html.DropDownListFor(Function(model) model.Habilitacoes, New SelectList(ViewBag.Habilitacoes, "KeyHL", "DescricaoHL", model.Habilitacoes), New With {.class = "FillHSpace"})
How can I declare the SelectedValue?
SelectedHabilitaco- whatever that is ;) ) on the model. And use it as the first parameter ofDropDownListFor- like in this answer: stackoverflow.com/questions/3386998/… (see Update 2).