I have a list of vehicle models:
private List<ModeloRastreador> modelo = new List<ModeloRastreador>();
I add the result that came from the bank
foreach (var m in modelo)
{
modeloRastreador.Add(new SelectListItem {
Text = m.Nome,
Value = Convert.ToString(m.ID)
});
}
Step into my viewbag
ViewBag.ModelosVeiculos = modeloVeiculos;
and for the dropdown
@Html.DropDownList("ModeloID", new SelectList(ViewBag.ModelosVeiculos, "value", "text"),
new {
style = "width:280px",
@class = "form-control form-control-last",
@id = "ModeloID"
})
Up to that, but I want to set a value, equal to the selected HTML.