Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Date format hiding null values

Reply
Thread Tools

Date format hiding null values

 
 
ken s
Guest
Posts: n/a
 
      10-18-2006
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?

 
Reply With Quote
 
 
 
 
Eliyahu Goldin
Guest
Posts: n/a
 
      10-18-2006
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]


"ken s" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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?
>



 
Reply With Quote
 
 
 
 
ken s
Guest
Posts: n/a
 
      10-19-2006
Thank you for the tip. That did it.
/Ken
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Script for Hiding/Un-Hiding Text On Click Ste Javascript 41 08-01-2007 02:35 PM
Date value set to current datetime, after recall the date value is null moonhk Java 5 10-11-2006 04:45 AM
"stringObj == null" vs "stringObj.equals(null)", for null check?? qazmlp1209@rediffmail.com Java 5 03-29-2006 10:37 PM
Date, date date date.... Peter Grison Java 10 05-30-2004 01:20 PM
Date Format - best way of converting a string into a date format Brian Candy ASP .Net 2 02-18-2004 02:13 PM



Advertisments