For whatever reason of which the Fates may only know, we experienced a difference in pulling data manually as a list of objects than we did in pulling a list of objects from an entity framework. The current work around to get an empty value in the null datetime field was to do the following in the RadGridView's CellFormatting event. We are using RadControls for Winforms 2011 Q1.
Oddly enough, as mentioned above, pulling the data as a list of objects from an entity framework does not have to have this work around. We tried having DateTime? MyDateField in the field list of the object without the code below. It would display '01/01/0001' for each null value in the DateTime column of the grid.
So the measure below is in place. It is very quick and does not cause a lot of overhead. Still I would prefer a better solution if someone has fought this before.
private void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e)
{
if (e.CellElement != null)
{
GridViewDataColumn dataColumn = e.CellElement.ColumnInfo as GridViewDataColumn;
if (dataColumn.Name == "MyDateField")
{
DateTime dtValue = (DateTime)e.CellElement.RowInfo.Cells[dataColumn.Name].Value;
if (dtValue == System.DateTime.MinValue)
{
e.CellElement.Text = "";
}
}
}
}