Results 1 to 2 of 2

Thread: DBNull

  1. #1

    Thread Starter
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075

    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:

    Code:
    <%# 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..

  2. #2
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497
    Looks like you got an extra comma in there.

    Code:
    <%# IIF(IsDBNull(Container.DataItem ("Display_Start_Date")), "", Container.DataItem("Display_Start_Date").ToShortDateString())%>
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width