Is it possible to show more than 1 information field in @Html.DropDownListFor?

1

I would like to show more than 1 description

No controlle
//lista 
var tbuscar = new TituloPosAplicacao();
var listar = tbuscar.ListarTodos();
ViewBag.TituloPos = new SelectList(listar, "IDTITULOPOSS", "DESCRICAO", "MODALIDADE");
Na View
<div class="col-md-3 form-group">
    @Html.LabelFor(x => x.IDTITULOPOSS)
    @Html.DropDownListFor(x => x.IDTITULOPOSS, ViewBag.TituloPos as SelectList, new { @class = "form-control" })
    @Html.ValidationMessageFor(x => x.IDTITULOPOSS)
</div>
    
asked by anonymous 02.08.2016 / 02:49

1 answer

1

So:

Controller

ViewBag.TituloPos = tbuscar.ListarTodos();

View

@Html.DropDownListFor(x => x.IDTITULOPOSS, 
    ((IEnumerable<TituloPosAplicacao>)ViewBag.TituloPos).Select(tpa =>
        new SelectListItem {
            Text = tpa.IDTITULOPOSS + " - " + tpa.DESCRICAO,
            Value = tpa.IDTITULOPOSS,
            Selected = (Model != null) && (Model.IDTITULOPOSS == tpa.IDTITULOPOSS)
        }), 
    "Escolha...", 
    htmlAttributes: new { @class = "form-control" }
)
    
02.08.2016 / 05:45