tags:

views:

41

answers:

0

I have a POCO class for an edit model

class PersonEditModel {
  public string ScreenName{get;set;}
}

It's common for ScreenName to be null when my domain model is converted into this PersonEditModel.

When I present this in MVC 2 form using the html helpers I get back an empty string (if the user didn't add anything into screenname), because the model binder can't tell the difference between empty and null string value.

Is there a way to tell the model binder to automap a particular string value to null?

So, instead of getting back ScreenName as "", I would get back null. When I persist this back to the Domain model, it's alot cleaner for the data model.