title: MVC model binding to list - only works on first item in list
body: <p>I have a page that contains multiple forms to edit questions for a single quiz, each question has its own list of answers. So for each question inside this quiz there is a form for which a user can edit the question (and answers), See below:</p>
  
  <pre><code>@model OLTINT.Areas.admin.ViewModels.OldQuizQAViewModel
  &lt;h1&gt;Edit @Model.QuizTitle quiz&lt;/h1&gt;
  &lt;hr /&gt;
  &lt;p class="breadcrumb"&gt;
      @Html.ActionLink(HttpUtility.HtmlDecode("&amp;#9668;") + " Back to List", "Quizzes", new { id = Model.CourseID }, new { @class = "" })
  &lt;/p&gt;
  @for (int j = 0; j &lt; Model.OldQuizQuestions.Count(); j++)
  {
      using (Ajax.BeginForm("EditQuiz", "Course", null, new AjaxOptions
      {
          HttpMethod = "POST",
          InsertionMode = InsertionMode.Replace,
          UpdateTargetId = "button"
      }))
      {
          @Html.AntiForgeryToken()
          @Html.HiddenFor(model =&gt; model.QuizID)
          @Html.HiddenFor(model =&gt; model.OldQuizQuestions[j].QuizQuestionID)
  
          &lt;p class="form_title"&gt;Question number @Model.OldQuizQuestions[j].Order&lt;/p&gt;
          &lt;div class="resize_input"&gt;@Html.EditorFor(model =&gt; model.OldQuizQuestions[j].Question)&lt;/div&gt;
          &lt;p class="form_title"&gt;@Html.LabelFor(model =&gt; model.OldQuizQuestions[j].Type)&lt;/p&gt;
          &lt;div class="resize_input"&gt;@Html.DropDownListFor(model =&gt; model.OldQuizQuestions[j].Type, ViewBag.types, "Please choose...", new { @class = "chosen-select" })&lt;/div&gt;
  
          &lt;p class="form_title"&gt;Choose correct answers&lt;/p&gt;
          Char x = 'a';
          for (int i = 0; i &lt; Model.OldQuizQuestions[j].OldQuizAnswers.Count(); i++)
          {
              x++;
              if (i == 0)
              {
                  x = 'a';
              }
              &lt;div style="display:table; width:100%;"&gt;
                  &lt;div class="divTableCell" style="padding:0 10px 10px 0; vertical-align:middle; min-width:6%;"&gt;
                      @Html.CheckBoxFor(model =&gt; model.OldQuizQuestions[j].OldQuizAnswers[i].Correct, new { style = "" })
                      @Html.LabelFor(model =&gt; model.OldQuizQuestions[j].OldQuizAnswers[i].Correct, "["+ x +"]")
                  &lt;/div&gt;
                  &lt;div class="divTableCell quiz_input"&gt;
                      @Html.HiddenFor(model =&gt; model.OldQuizQuestions[j].OldQuizAnswers[i].QuizAnsID)
                      @Html.EditorFor(model =&gt; model.OldQuizQuestions[j].OldQuizAnswers[i].Answer)
                  &lt;/div&gt;
              &lt;/div&gt;
          }
          &lt;div class="button_container"&gt;
              &lt;p id="button"&gt;&lt;/p&gt;
              @Html.ActionLink("Delete this question", "DeleteQuestion", new { id = Model.OldQuizQuestions[j].QuizQuestionID }, new { @class = "button button_red button_not_full_width" })
              &lt;input type="submit" value="Save" class="button button_orange button_not_full_width" /&gt;
          &lt;/div&gt;
          &lt;hr /&gt;
      }
  }
  </code></pre>
  
  <p><strong>OldQuizQAViewModel:</strong></p>
  
  <pre><code>public class OldQuizQAViewModel
  {
      public int CourseID { get; set; }
      public int? QuizID { get; set; }
      public string QuizTitle { get; set; }
      public IList&lt;OldQuizQuestions&gt; OldQuizQuestions { get; set; }
  }
  </code></pre>
  
  <p><strong>OldQuizQuestions:</strong></p>
  
  <pre><code>public class OldQuizQuestions
  {
      [Key]
      public int QuizQuestionID { get; set; }
      public int OldQuizID { get; set; }
      [Required]
      public string Question { get; set; }
      [Required]
      public int Order { get; set; }
      [Required]
      public int Type { get; set; }
  
      public virtual IList&lt;OldQuizAnswers&gt; OldQuizAnswers { get; set; }
      public virtual OldQuiz OldQuiz { get; set; }
  
  }
  </code></pre>
  
  <p><strong>OldQuizAnswers:</strong></p>
  
  <pre><code>public class OldQuizAnswers
  {
      [Key]
      public int QuizAnsID { get; set; }
      public int QuizQuestionID { get; set; }
      public string Answer { get; set; }
      public int Order { get; set; }
      public bool Correct { get; set; }
      public bool Chosen { get; set; }
  
      public virtual OldQuizQuestions OldQuizQuestions { get; set; }
  }
  </code></pre>
  
  <p><strong>Controller:</strong></p>
  
  <pre><code>    [HttpPost]
      [ValidateAntiForgeryToken]
      public ActionResult EditQuiz(OldQuizQAViewModel model)
      {
          var questiondata = model.OldQuizQuestions.Single();
  
          if (ModelState.IsValid)
          {
              OldQuizQuestions updatequestion = db.OldQuizQuestions
                  .SingleOrDefault(x =&gt; x.QuizQuestionID == questiondata.QuizQuestionID);
  
              updatequestion.Question = questiondata.Question;
              updatequestion.Type = questiondata.Type;
  
              db.Entry(updatequestion).State = EntityState.Modified;
              db.SaveChanges();
  
              foreach (var answer in questiondata.OldQuizAnswers)
              {
                  var updateanswer = updatequestion.OldQuizAnswers
                      .First(x =&gt; x.QuizAnsID == answer.QuizAnsID);
  
                  updateanswer.Answer = answer.Answer;
                  updateanswer.Correct = answer.Correct;
  
                  db.Entry(updateanswer).State = EntityState.Modified;
                  db.SaveChanges();
              }
  
              return Content("&lt;span style='font-weight:300; font-size:1.2em; color: green; '&gt;Saved!&lt;/span&gt;");
          }
          return Content("&lt;span class='errortext'&gt;Please correct the marked fields!&lt;/span&gt;");
      }
  </code></pre>
  
  <p>Now this works fine if I want to edit the first question but when I edit anything else my controller just says null but when I check the data that's being posted everything is there (for example when i try to edit question 2):</p>
  
  <p><a href="https://i.stack.imgur.com/4FfEp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4FfEp.png" alt="enter image description here"></a></p>
  
  <p>I've had a look around on here at the many queries about model binding to a list but none have helped. Can anyone see where i'm going wrong with this?</p>