title: ASP.NET MVC 5 : Editing multiple records in a view and model binding (Bulk data update)
body: <p>I need correction on the code below.
  I have 2 classes "Employee" and "Child". 
  When I want to create a new Employee, I would like to be able to create in that same form the related Child (2 Children maximum).</p>
  
  <p>Below are the models</p>
  
  <pre><code>public class Employee
  {
      public int EmployeeID { get; set; }
      public string Name { get; set; }
      public string Surname { get; set; }
  
      public int ChildID { get; set; }
  
      public virtual ICollection&lt;Child&gt; Childs { get; set; }
  
  }
  
  public class Child
  {
      public int ChildID { get; set; }
      public string NameChild { get; set; }
      public string SurnameChild { get; set; }
  
      public virtual Employee Employee { get; set; }
  }
  </code></pre>
  
  <p>The Employee controller</p>
  
  <pre><code>public class EmployeController : Controller
  {
      private ComideContext db = new ComideContext();
  
      // GET: Employe/Create
      public ActionResult Create()
      {
          List&lt;Child&gt; model = new List&lt;Child&gt;();
          return View(model);
      }
  
      [HttpPost]
      [ValidateAntiForgeryToken]
      public ActionResult Create([Bind(Include = "EmployeID,Name,Surname,ChildID")] Employee employee)
      {
          if (ModelState.IsValid)
          {
              db.Employes.Add(employe);
              db.SaveChanges();
              return RedirectToAction("Index");
          }
  
          return View(employe);
      }
  }
  </code></pre>
  
  <p>The View of the Employee form</p>
  
  <pre><code>@using (Html.BeginForm())
  {
      @Html.AntiForgeryToken()
  
      &lt;div class="form-horizontal"&gt;
          &lt;h4&gt;Employe&lt;/h4&gt;
          &lt;hr /&gt;
          @Html.ValidationSummary(true, "", new { @class = "text-danger" })
          &lt;div class="form-group"&gt;
              @Html.LabelFor(model =&gt; model.Name, htmlAttributes: new { @class = "control-label col-md-2" })
              &lt;div class="col-md-10"&gt;
                  @Html.EditorFor(model =&gt; model.Name, new { htmlAttributes = new { @class = "form-control" } })
                  @Html.ValidationMessageFor(model =&gt; model.Name, "", new { @class = "text-danger" })
              &lt;/div&gt;
          &lt;/div&gt;
  
          &lt;div class="form-group"&gt;
              @Html.LabelFor(model =&gt; model.Surname, htmlAttributes: new { @class = "control-label col-md-2" })
              &lt;div class="col-md-10"&gt;
                  @Html.EditorFor(model =&gt; model.Surname, new { htmlAttributes = new { @class = "form-control" } })
                  @Html.ValidationMessageFor(model =&gt; model.Surname, "", new { @class = "text-danger" })
              &lt;/div&gt;
          &lt;/div&gt;
  
          @for (int i=0; i&lt;2; i++ )
          {
              &lt;div class="form-group"&gt;
                  @Html.LabelFor(model =&gt; model.NameChild, htmlAttributes: new { @class = "control-label col-md-2" })
                  &lt;div class="col-md-10"&gt;
                      @Html.EditorFor(model =&gt; model.NameChild, new { htmlAttributes = new { @class = "form-control" } })
                      @Html.ValidationMessageFor(model =&gt; model.NameChild, "", new { @class = "text-danger" })
                  &lt;/div&gt;
              &lt;/div&gt;
              &lt;div class="form-group"&gt;
                  @Html.LabelFor(model =&gt; model.SurnameChild, htmlAttributes: new { @class = "control-label col-md-2" })
                  &lt;div class="col-md-10"&gt;
                      @Html.EditorFor(model =&gt; model.SurnameChild, new { htmlAttributes = new { @class = "form-control" } })
                      @Html.ValidationMessageFor(model =&gt; model.SurnameChild, "", new { @class = "text-danger" })
                  &lt;/div&gt;
              &lt;/div&gt;
          }
  
  
          &lt;div class="form-group"&gt;
              &lt;div class="col-md-offset-2 col-md-10"&gt;
                  &lt;input type="submit" value="Create" class="btn btn-default" /&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  }
  </code></pre>
  
  <p>Any help/thoughts would be most appreciated.</p>
  
  <p>Thank you.</p>