title: ASP .Net Core Model Binding To A Collection
body: <p>I'm new to ASP .Net Core 1.0 and I'm trying to bind a view to a model that contains a collection of same object. The main model is a questionnaire and may contain any count of questions with different types. But my problem is inside the ActionResult method, my List property is always null during post.</p>
  
  <p>This is the form:</p>
  
  <pre><code>&lt;form id="mainForm" asp-controller="Default" asp-action="PersonalDetails" asp-route-sectionTypeCode="@Model.SectionTypeCode" asp-route-sectionNumber="@Model.SectionNumber" method="post" asp-anti-forgery="false"&gt;
          @{
              for (Int32 i = 0; i &lt; Model.Questions.Count; i++)
              {
                  string spacerValue = "";
                  if (i == Model.Questions.Count - 1)
                  {
                      spacerValue = "extraLargeSpacerBottom";
                  }
                  &lt;div class="form-group @spacerValue"&gt;
                      &lt;label&gt;@Model.Questions[i].QuestionTitle&lt;/label&gt;
                      @{
                          switch (Model.Questions[i].QuestionTypeCode)
                          {
                              case 1:
                                  &lt;input asp-for="Questions[i].Value" class="form-control appInput" type="text"&gt;
                                  break;
  
                              case 2:
                                  &lt;input asp-for="Questions[i].Value" class="form-control appInput" type="number"&gt;
                                  break;
  
                              case 3:
                                  &lt;select asp-for="Questions[i].Value" class="form-control appInput" asp-items="Model.Questions[i].QuestionOptions"&gt;&lt;/select&gt;
                                  break;
  
                              case 4:
                                  &lt;input asp-for="Questions[i].Value" class="form-control appInput" type="date"&gt;
                                  break;
  
                              case 5:
                                  &lt;div&gt;
                                      &lt;label class="radio-inline"&gt;
                                          &lt;input asp-for="Questions[i].Value" value="true" type="radio"&gt;&lt;span class="radioSpace"&gt;Yes&lt;/span&gt;
                                      &lt;/label&gt;
                                      &lt;label class="radio-inline"&gt;
                                          &lt;input asp-for="Questions[i].Value" value="false" type="radio"&gt;&lt;span class="radioSpace"&gt;No&lt;/span&gt;
                                      &lt;/label&gt;
                                  &lt;/div&gt;
                                  break;
  
                              case 6:
                                  &lt;input asp-for="Questions[i].Value" class="form-control appInput" type="number"&gt;
                                  break;
                          }
                      }
                  &lt;/div&gt;
              }
          }
      &lt;/form&gt;
  </code></pre>
  
  <p>And this is the _Question class:</p>
  
  <pre><code>public class _Question
  {
      #region Properties
      public string QuestionTitle { get; private set; }
      public string QuestionHelp { get; private set; }
      public Int32 QuestionTypeCode { get; private set; }
      public string ValidationMessage { get; private set; }
      public List&lt;SelectListItem&gt; QuestionOptions { get; private set; }
  
      public dynamic Value { get; set; }
      #endregion
  
      public _Question() { }
  
      public _Question(Int32 questionTypeCode, string questionTitle, string questionHelp, List&lt;SelectListItem&gt; options = null)
      {
          QuestionTypeCode = questionTypeCode;
          QuestionTitle = questionTitle;
          QuestionHelp = questionHelp;
          QuestionOptions = options;
  
          switch (questionTypeCode)
          {
              case 1:
                  ValidationMessage = "Please enter a text value";
                  break;
  
              case 2:
                  ValidationMessage = "Please enter a numeric value";
                  break;
  
              case 4:
                  ValidationMessage = "Please enter a date value";
                  break;
  
              case 6:
                  ValidationMessage = "Please enter a currency value";
                  break;
          }
      }
  }
  </code></pre>
  
  <p>The main model contains a list of _Question objects that are being generated at runtime from a database.</p>
  
  <p>Can anybody please help me about my null result?</p>