title: MVC post a list of complex objects
body: <p>I have a FeedbackViewModel that contains a list of questions:</p>
  
  <pre><code>public class FeedbackViewModel
  {
      public List&lt;QuestionViewModel&gt; Questions { get; set; }
  }
  </code></pre>
  
  <p>This QuestionViewModel is an object that can be inherited by 5 different types of questions</p>
  
  <pre><code>public class QuestionViewModel
  {
      public string QuestionText { get; set; }
      public string QuestionType { get; set; }
  }
  </code></pre>
  
  <p>An example of one of the inheriting question types:</p>
  
  <pre><code>public class SingleQuestionViewModel : QuestionViewModel
  {
      public string AnswerText { get; set; }
  }
  </code></pre>
  
  <p>In the <code>HttpGet</code> of the <code>Index</code> action in the controller I get the questions from the database and add the correct question type in list of question in the <code>FeedbackViewModel</code> Then I render this model in the view:</p>
  
  <pre><code>@using (Html.BeginForm())
  {
      //foreach (var item in Model.Questions)
      for (int i = 0; i &lt; Model.Questions.Count; i++)
      {
          &lt;div class="form-group"&gt;
              @Html.DisplayFor(modelItem =&gt; Model.Questions[i].QuestionText, new { @class = "control-label col-md-4" })
              &lt;div class="col-md-6"&gt;
                  @if (Model.Questions[i].QuestionType == "Single")
                  {
                      @Html.EditorFor(modelItem =&gt; (Model.Questions[i] as OpenDataPortal.ViewModels.SingleQuestionViewModel).AnswerText)
                  }
                  else if (Model.Questions[i].QuestionType == "Multiple")
                  {
                      @Html.TextAreaFor(modelItem =&gt; (Model.Questions[i] as OpenDataPortal.ViewModels.SingleQuestionViewModel).AnswerText)
                  }
                  else if (Model.Questions[i].QuestionType == "SingleSelection")
                  {
                      @Html.RadioButtonForSelectList(modelItem =&gt; (Model.Questions[i] as OpenDataPortal.ViewModels.SingleSelectionQuestionViewModel).SelectedAnswer,
                                                                  (Model.Questions[i] as OpenDataPortal.ViewModels.SingleSelectionQuestionViewModel).SelectionAnswers)
                  }
                  else if (Model.Questions[i].QuestionType == "MultipleSelection")
                  {
                      @Html.CustomCheckBoxList((Model.Questions[i] as OpenDataPortal.ViewModels.MultipleSelectionQuestionViewModel).AvailableAnswers)
                  }
                  else if (Model.Questions[i].QuestionType == "UrlReferrer")
                  {
                      @Html.EditorFor(modelItem =&gt; (Model.Questions[i] as OpenDataPortal.ViewModels.SingleQuestionViewModel).AnswerText)
                  }
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;br /&gt;
      }
  
      &lt;br /&gt;
      &lt;button type="submit"&gt;Submit&lt;/button&gt;
  }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/cjEVp.png" alt="enter image description here"></p>
  
  <hr>
  
  <p>Now, I simply can't get it to post the list of questions in the model. Is it even possible to post a list of different object types?</p>
  
  <hr>
  
  <p><strong>Edit:</strong> Following is the list of data within the post that I discovered using Fiddler:</p>
  
  <p><img src="https://i.stack.imgur.com/pmZHg.png" alt="enter image description here"></p>