I have two models:
class ModelIn{ public string FirstName { get; set; } public string LastName { get; set; } public string Address { get; set; } } class ModelOut{ public ModelOut(){ People = new List<ModelIn>();} public List<ModelIn> People { get; private set;} public string Country { get; set; } }
And I have a Controller editing ModelOut:
public ActionResult People() { ... return View(SomeModelOutInstanceWith3People); } [HttpPost] public ActionResult(ModelOut items) { ... }
I think that
<% using (Html.BeginForm()) { %> <%: Html.EditorFor(m => Model.Country) %> <% for(int i = 0; i < Model.People.Count; ++i){ %> <%: Html.EditorFor(m => Model.People[i].FirstName) %> <%: Html.EditorFor(m => Model.People[i].LastName) %> <%: Html.EditorFor(m => Model.People[i].Address) %> <% } %> <input type="submit" /> <% } %>
Everything works fine, but in post action I have empty ModelOut elements. In the logs, I see that the data is being sent correctly.
I tried everything, nothing works.
source share