I'm using Razor
to generate a SelectList
like this:
@Html.DropDownList("StatusImovel", new SelectList(ViewBag.ListaStatus, "IdStatus", "Descricao"), new { @hidden = "hidden", @multiple = "multiple", @form = "nulo" })
I need it to load already with some selected items, so I'm trying this:
@Html.DropDownList("StatusImovel", new SelectList(ViewBag.ListaStatus, "IdStatus", "Descricao", ViewBag.StatusSelecionados), new { @hidden = "hidden", @multiple = "multiple", @form = "nulo" })
Being ViewBag.StatusSelecionados
is array int[]
with IdStatus
I want.
but it is not working.
Do you have any way to do this?