asp.net mvc custom model binding in an update entity scenario

Posted by mctayl on Stack Overflow See other posts from Stack Overflow or by mctayl
Published on 2010-05-18T19:45:18Z Indexed on 2010/05/18 19:50 UTC
Read the original article Hit count: 256

Filed under:
|

Hi I have a question about model binding. Imagine you have an existing database entity displayed in a form and you'd like to edit some details, some properties eg createddate etc are not bound to the form, during model binding, these properties are not assigned to the model as they are not on the http post data or querystrong etc, hence their properties are null. In my controller method for update , Id just like to do

public ActionResult Update( Entity ent) { //Save changes to db }

but as some properties are null in ent, they override the existing database fields which are not part of the form post data, What is the correct way to handle this? Ive tried hidden fields to hold the data, but model binding does not seem to assign hidden fields to the model. Any suggestions would be appreciated

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about asp.net-mvc