By Ross L. Rooker, Sr. - 2/11/2011
In our BO Mapper we set the Datetime as follows:
NULL VALUE OPTION: Return Alternate on Null / Set Null on Alternate(value)
NULL REPLACEMENT VALUE: new DateTime(1800, 1, 1)
This works great in the SF Date controls at times in that 01/01/1800 is NOT wriitten back to the database when using the SF control.
Here is my issue: I have an Infragistics grid bound to a BO. In the grid the date always shows 01/01/1800 when the value in the table for a date is NULL. My thoughts are that the BO is returning 01/01/1800 even if the date in null.
|
By Ross L. Rooker, Sr. - 2/11/2011
I could take the BO Mapper settings and change them if that is the fix but my concern is then that the SF DateBox controls will then have an issue. What do you suggest as an alternative to have null dates show up as null or blank in grids rather than 01/01/1800?
|
By Ross L. Rooker, Sr. - 2/17/2011
FYI... I solved my issue by adding the following to the Infragistics grid InitializeRow method:
for (int i = 0; i <= e.Row.Cells.Count - 1; i++)
{
if (e.Row.Cells[i].Value.ToString() == "1/1/1800 12:00:00 AM")
{
e.Row.Cells[i].Hidden = true;
}
}
For a regular .net DataGrid I added this to the Cell Formatting event:
if (e.ColumnIndex >= 0)
{
if (e.Value != null)
{
if (e.Value.ToString() == "1/1/1800 12:00:00 AM")
{
e.Value = "";
}
}
}
And actually I took the above code, moved it to a static class and called it from there to minimize the coding.
This gets rid of the ugly 1/1/1800 from grids.
|
By Edhy Rijo - 2/17/2011
Hi Ross,
Thanks for sharing this tip, very nice.
|
|