Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The default model binder will bind nested objects, you do not need to create your own model binder for this scenario.</p> <p>See: <a href="http://lostechies.com/jimmybogard/2011/09/07/building-forms-for-deep-view-model-graphs-in-asp-net-mvc/" rel="nofollow noreferrer">http://lostechies.com/jimmybogard/2011/09/07/building-forms-for-deep-view-model-graphs-in-asp-net-mvc/</a> and on SO <a href="https://stackoverflow.com/questions/3928120/defaultmodelbinder-not-binding-nested-model">DefaultModelBinder not binding nested model</a></p> <p>I suspect your problem is that your editor template is not returning anything via the post back so the nested object is null. The lines in your editor template:</p> <pre><code>@Html.DropDownListFor(Model =&gt; Model.Day, new List&lt;SelectListItem&gt;()) @Html.DropDownListFor(Model =&gt; Model.Month,new List&lt;SelectListItem&gt;()) @Html.DropDownListFor(Model =&gt; Model.Year, new List&lt;SelectListItem&gt;()) </code></pre> <p>Will give you three controls with empty drop downs, you will not be able to select anything from these drop downs as you have not supplied any values to them. If there is no value then they are not sent across the wire and cannot be model bound. To start of with change you editor template to:</p> <pre><code>@Html.TextBoxFor(Model =&gt; Model.Day) @Html.TextBoxFor(Model =&gt; Model.Month) @Html.TextBoxFor(Model =&gt; Model.Year) </code></pre> <p>This will allow you to actually enter some data onto to form. Once this is working you can then change the text boxes back to drop downs but you will need to supply values for the select lists, again, just creating new empty lists will not allow you to select any values.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload