Reputation: 63
I have an object "product" build from a database. it has 3 attributes : - Id can't be NULL - Ref can't be NULL - Designation can be NULL
So I'm using an AjaxForm and @Html.EditorFor(model => model.Designation) to update the "Designation" field My problem is when my Controller received the "product" object, Product's Id is well filled with the original value, however Product's Ref is null
I thought about 2 solutions : Add a Ref Field in my AjaxForm not editable, or the worst : In my controller research the ref of my product using the Id ( very bad :s )
Could you advice me about how to do this clean. Thank you !
Upvotes: 0
Views: 540
Reputation: 16137
You probably have to add in the Ref Field, so that the page knows about mapping that field when it goes back to your controller, but you can make it hidden using HiddenFor:
@Html.HiddenFor(model => model.Ref)
Upvotes: 1