Date format hiding null values

K

ken s

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?
 
E

Eliyahu Goldin

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top