1
I have a dropdowlist
that carries RamosDeAtidade
, want to know how I do to my Edit view, already be selected the branch I registered, in my Controller, at Action Edit
It’s like this:
var cliente = _clienteAppService.ObterPorId(id ?? Guid.Empty);
ViewBag.RamoAtividadeId = new SelectList(_ramoDeAtividadeAppService.ObterTodos(),
"RamoDeAtividadeId",
"Descricao",
cliente.RamoAtividadeId);
return PartialView(cliente);
in my view, I did the following Razor:
@Html.DropDownListFor(model => model.RamoAtividadeId, (IEnumerable<SelectListItem>)ViewBag.RamoAtividadeId, new { @class = "form-control-sm", style = "max-width:156px; padding:0" })
in this way, the branch that I registered is never selected.
you have done this by passing the third parameter in the class
SelectList
!– novic
but still, the branch of activity that I registered is not selected. :/
– Rafael Passos