title: MVC Nested model binding only partially working - what am I missing?
body: <p>I have a ViewModel called AssetSearchModel with a property of type: List. </p>
  
  <p>When I post from the ViewModel, all the properties of my List get binded back to the model successfully, except for this one: <code>public DomainsDto DomainControl { get; set; }</code> which is defined at the bottom.</p>
  
  <p>That domaincontrol has a couple of properties and then its own nested list... none of its properties get set, they are all null</p>
  
  <pre><code>public class AssetSearchModel
  {
      public List&lt;SearchControlModel&gt; SearchControls { get; set; }
  
      public AssetSearchModel()
      {
      }
  
  }
  
  public class SearchControlModel
  {
  
      /// &lt;summary&gt;
      /// Asset identifier.
      /// &lt;/summary&gt;
      [DisplayName("AssetId ID")]
      public int SearchOptionID { get; set; } // this gets bound ok
  
      [DisplayName("Asset Customer ID")]
      public int AssetCustomerID { get; set; } // this gets bound ok
  
      [DisplayName("Portal ID")]
      public int PortalID { get; set; } // this gets bound ok
  
      [DisplayName("Calling Page")]
      public string CallingPage { get; set; } // this gets bound ok
  
      [DisplayName("Display Control")]
      public string DisplayControl { get; set; } // this gets bound ok
  
      [DisplayName("Display Text")]
      public string DisplayText { get; set; } // this gets bound ok
  
      public string ControlValue { get; set; } // this gets bound ok
  
      [DisplayName("Search Table")]
      public string SearchTable { get; set; } // this gets bound ok
  
      [DisplayName("Search Column")]
      public string SearchColumn { get; set; } // this gets bound ok
  
      [DisplayName("Source Table")]
      public string SourceTable { get; set; } // this gets bound ok
  
      [DisplayName("Source Display Column")]
      public string SourceDisplayColumn { get; set; } // this gets bound ok
  
      [DisplayName("Source Value Column")]
      public string SourceValueColumn { get; set; } // this gets bound ok
  
      [DisplayName("SourceCustomFilter")]
      public string SourceCustomFilter { get; set; } // this gets bound ok
  
      [DisplayName("SortOrder")]
      public int SortOrder { get; set; } // this gets bound ok
  
      [DisplayName("DomainControl")]
      public DomainsDto DomainControl { get; set; } // THIS DOES NOT BIND
  
      public SearchControlModel()
      {
  
  
  
      }
  
  }
  </code></pre>
  
  <hr>
  
  <pre><code>public class DomainsDto
  {
      public int DomainMasterId;      // this does not bind
      public string DisplayName;     // this does not bind
      public List&lt;DomainDto&gt; Domains;  // this does not bind
      public DomainsDto()
      {
  
      }
  
  }
  
  [DataContract(Name = "Domain", Namespace = "http://www.comcom.com/")]
  
  public class DomainDto
  {
      [DataMember]
      public int DomainID { get; set; }   // this does not bind
  
      [DataMember]
      public string DomainName { get; set; }  // this does not bind
  
      [DataMember]
      public bool Checked { get; set; }   // this does not bind
  
  
      public DomainDto()
      {
  
      }
  }
  </code></pre>
  
  <p>and my view:</p>
  
  <pre><code>         @for (int y = 0; y &lt; Model.SearchControls.Count; y++)
       {
  
          @Html.Label("Search option: " + Model.SearchControls[y].DisplayText)
          &lt;br /&gt;
          @Html.HiddenFor(x =&gt; x.SearchControls[y].DisplayText)
          @Html.HiddenFor(x =&gt; x.SearchControls[y].CallingPage)
          @Html.HiddenFor(x =&gt; x.SearchControls[y].DisplayControl)
          @Html.HiddenFor(x =&gt; x.SearchControls[y].SourceCustomFilter)
          @Html.HiddenFor(x =&gt; x.SearchControls[y].SearchTable)
          @Html.HiddenFor(x =&gt; x.SearchControls[y].SearchColumn)
          @Html.HiddenFor(x =&gt; x.SearchControls[y].SourceValueColumn)
  
  
           if (Model.SearchControls[y].DomainControl != null)
           {
  
               @Html.HiddenFor(x =&gt; x.SearchControls[y].DomainControl.DisplayName) 
  
               @Html.HiddenFor(x =&gt; x.SearchControls[y].DomainControl.DomainMasterId)
  
               if (Model.SearchControls[y].DomainControl.Domains != null)
               {
                   for (int z = 0; z &lt; Model.SearchControls[y].DomainControl.Domains.Count; z++)
                   {
  
                      @Html.HiddenFor(x =&gt; x.SearchControls[y].DomainControl.Domains[z].DomainID)
                      @Html.HiddenFor(x =&gt; x.SearchControls[y].DomainControl.Domains[z].DomainName)
                      @Html.HiddenFor(x =&gt; x.SearchControls[y].DomainControl.Domains[z].Checked)
  
  
                      &lt;br /&gt;
                   }
               }
           }
  
           &lt;br /&gt;
           &lt;br /&gt;
           &lt;hr width=100px /&gt;
  
  
       }
  </code></pre>
  
  <p>the html (sorry for the single line, it wouldn't let me paste it in differently)</p>
  
  <pre><code>&lt;label for="Search_option:_Product_Lines"&gt;Search option: Product Lines&lt;/label&gt; &lt;input id="SearchControls_1__DisplayText" name="SearchControls[1].DisplayText" type="hidden" value="Product Lines" /&gt; &lt;input id="SearchControls_1__CallingPage" name="SearchControls[1].CallingPage" type="hidden" value="AssetSearch" /&gt; &lt;input id="SearchControls_1__DisplayControl" name="SearchControls[1].DisplayControl" type="hidden" value="M" /&gt; &lt;input id="SearchControls_1__SourceCustomFilter" name="SearchControls[1].SourceCustomFilter" type="hidden" value="26" /&gt; &lt;input id="SearchControls_1__SearchTable" name="SearchControls[1].SearchTable" type="hidden" value="AssetDomainValue" /&gt; &lt;input id="SearchControls_1__SearchColumn" name="SearchControls[1].SearchColumn" type="hidden" value="Brand" /&gt; &lt;input id="SearchControls_1__SourceValueColumn" name="SearchControls[1].SourceValueColumn" type="hidden" value="DomainCodeValueID" /&gt;   &lt;input id="SearchControls_1__DomainControl_DisplayName" name="SearchControls[1].DomainControl.DisplayName" type="hidden" value="Product Line" /&gt; &lt;input id="SearchControls_1__DomainControl_DomainMasterId" name="SearchControls[1].DomainControl.DomainMasterId" type="hidden" value="26" /&gt;  &lt;input id="SearchControls_1__DomainControl_Domains_0__DomainID" name="SearchControls[1].DomainControl.Domains[0].DomainID" type="hidden" value="43680" /&gt; &lt;input id="SearchControls_1__DomainControl_Domains_0__DomainName" name="SearchControls[1].DomainControl.Domains[0].DomainName" type="hidden" value="YORK" /&gt; &lt;input id="SearchControls_1__DomainControl_Domains_0__Checked" name="SearchControls[1].DomainControl.Domains[0].Checked" type="hidden" value="False" /&gt;                        &lt;input id="SearchControls_1__DomainControl_Domains_1__DomainID" name="SearchControls[1].DomainControl.Domains[1].DomainID" type="hidden" value="43683" /&gt; &lt;input id="SearchControls_1__DomainControl_Domains_1__DomainName" name="SearchControls[1].DomainControl.Domains[1].DomainName" type="hidden" value="Johnson Controls" /&gt; &lt;input id="SearchControls_1__DomainControl_Domains_1__Checked" name="SearchControls[1].DomainControl.Domains[1].Checked" type="hidden" value="False" /&gt;                        &lt;br /&gt;
  </code></pre>