Telerik MVC DropDownList not binding to model property
I have the following DropDownList in a Create view.开发者_如何学C I populate the list dynamically, cascading from two other lists, and all goes well before posting. The list populates correctly and I select a suburb. However, on the model passed into the Create
action method, SuburbId
remains null. What is going on here?
<div class="editor-field">
@(Html.Telerik().DropDownListFor(model => model.DetailItem.SuburbId)
.Name("Suburbs")
.Enable(false)
)
</div>
(DetailItem
is a property on the view model that holds a reference to the data model.)
Thanks to @korchev's suggestion above, I removed the Name call, which was actually assigning an explicit name in conflict with the DetailItem_SuburbId
name generated and assigned by the model binder.
精彩评论