Thursday, August 15, 2013

DevExpress MVC GridView: Allow empty string for empty textbox cell

I've been struggling for too long on this. I hope this helps a few.

Instead of writing the usual:

settings.Columns.Add("Name");

use this:

settings.Columns.Add(col =>
{
 col.FieldName = "Name";
 var tbxProperties = col.PropertiesEdit as TextBoxProperties;
 tbxProperties.ConvertEmptyStringToNull = false;
});

Not pretty, but does work.

No comments: