0
I have these two classes and I need to popular a Dropdownlistfor with the information of the classes ModeloVeiculo
, this Dropdownlistfor will be made in the
create.cshtml of the class Veiculo
, I believe the correct question would be, how to upload information to a Dropdownlistfor, and this information is from a foreign key!
public class Veiculo
{
public int ID { get; set; }
public string Tipo { get; set; }
public ModeloVeiculo ModeloVeiculo { get; set; }
}
public class ModeloVeiculo
{
public int ID { get; set; }
public string Descricao { get; set; }
}
View:
<div class="editor-field">
@Html.DropDownListFor(model => model.ModeloVeiculo,
new SelectList(Model.ModeloVeiculo, "ID", "Descricao"))
@Html.ValidationMessageFor(model => model.ModeloVeiculo)
</div>
@Tiago Silva said silly I really need a Dropdownlistfor!
– Camuratti