Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_beginners thread: DBNull


Message #1 by "eyetalion" <eyetalion1@h...> on Tue, 28 Jan 2003 19:20:18
I have a datagrid that gets populated when the page is selected. One of 
my fields is a date field, so I formated it: Container.DataItem 
("Start_Date").ToShortDateString. In the DB this field can be NULL so in 
my code I check for DBNULL:

<%# IIF(IsDBNull(Container.DataItem ("Display_Start_Date")), "", 
Container.DataItem,Container.DataItem 
("Display_Start_Date").ToShortDateString())%>

I still get this error when a NULL field is returned:

Public member 'ToShortDateString' on type 'DBNull' not found. 

any suggestions? is there another way to format the date in a datagrid so 
it doesn't return the time?

thanks..
Message #2 by "Bob Clegg" <bclegg@a...> on Wed, 29 Jan 2003 08:26:59 +1300
Hi,
I had something similar in retrieving a date field from an sql database.
The is DBNUll test threw an error.
This solved it:
If cmdSource.GetSqlDateTime(1).IsNull Then
There may be something similar in asp.
Regards
Bob

-----Original Message-----
From: eyetalion [mailto:eyetalion1@h...] 
Sent: Tuesday, 28 January 2003 7:20 p.m.
To: aspx_beginners
Subject: [aspx_beginners] DBNull

I have a datagrid that gets populated when the page is selected. One of 
my fields is a date field, so I formated it: Container.DataItem 
("Start_Date").ToShortDateString. In the DB this field can be NULL so in

my code I check for DBNULL:

<%# IIF(IsDBNull(Container.DataItem ("Display_Start_Date")), "", 
Container.DataItem,Container.DataItem 
("Display_Start_Date").ToShortDateString())%>

I still get this error when a NULL field is returned:

Public member 'ToShortDateString' on type 'DBNull' not found. 

any suggestions? is there another way to format the date in a datagrid
so 
it doesn't return the time?

thanks..


  Return to Index