all groups > asp.net datagrid control > october 2006 >
You're in the

asp.net datagrid control

group:

Date format hiding null values


Date format hiding null values ken s
10/17/2006 8:40:02 PM
asp.net datagrid control:
Greetings,
I'm using a custom date format to display date values in a BoundField in a
GridView. Here's the line that formats the date value:

DataFormatString="{0:MM/dd/yy}"

It works fine as long as there's a date in the field being displayed. But
if the field is null, it displays 01/01/01. I'd prefer that it either show a
blank field when it's null. How can I do this?
Re: Date format hiding null values Eliyahu Goldin
10/18/2006 12:00:00 AM
Handle RowDataBound (or ItemDataBound) event. For ever row item check the
value in the data field (available via DataItem property). If it is null,
set the required cell (available via Cells property) text to blank.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]


[quoted text, click to view]

Re: Date format hiding null values ken s
10/18/2006 10:58:01 PM
Thank you for the tip. That did it.
AddThis Social Bookmark Button