I’m trying to save multiple models but have problem with the dropdownlist of the model.
I got the following error: No information ViewData type ‘IEnumerable ‘ with key ‘[0]. TypeBienId’.
Here are some files:
Controller GET:
public ActionResult RDummy()
{
List<BI> bis = new List<BI>();
BI bi1 = new BI();
ViewBag.TypeBienId = new SelectList(db.TypeBiens, "TypeBienId", "cnom");
bis.Add(bi1);
return View(bis);
}
My View:
@model IEnumerable<SIBI.Models.BI>
@using (Html.BeginForm()) {
@Html.EditorForModel()
<p>
<input type="submit" value="Crear" />
</p>
}
My Template in the EditorTemplates Folder:
@model SIBI.Models.BI
@Html.DropDownList("TypeBienId", String.Empty)<br />
@Html.ValidationMessageFor(model => model.TypeBienId)
Any ideas of what the problem is and how to resolved?
Try using this in your EditorTemplate: