MVC binding form data problem.

Posted by John on Stack Overflow See other posts from Stack Overflow or by John
Published on 2010-04-06T13:34:23Z Indexed on 2010/04/06 14:33 UTC
Read the original article Hit count: 228

Filed under:

I am using an object that matches all the fields in my form. I then use the default binding to populate the object in my action, like this;

public ActionResult GetDivisionData(DivisionObj FormData)

My DivisionObj initializes all it's values to string.empty in the constructor.

The problem is that when the binder populates the model from the posted form data, any data that is not posted is set to null in the object, eventhough I initialized the object to contain empty strings.

Is there a way to change this so that unposted data will be an empty string.

© Stack Overflow or respective owner

Related posts about asp.net-mvc