🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.csharpbuilder.aspdotnet.general
Article #41

Databinding to a property and SQL NULL value ?

#41
From: Ramtin
Date: Fri, 15 Apr 2005 21:48
15 lines
1314 bytes
Hi
 suppose this binding :

<asp:Label runat="server" Text='<%# MyFunction( (DateTime)
DataBinder.Eval(Container,"DataItem.ExpireDate")) %>'
ID="Label1"></asp:Label>

which MyFunction is a function with a DateTime parameter and string result.
The problem is here: the field ExpireDate can have SQL NULL value and this
with throw an exception because of invalid type casting (NULL to DateTime).

What should I do to avoid this exception?

Thanks
Ramtin K.
Technical Details
Message-ID: <426036cb@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!newshub.sdsu.edu!news-hog.berkeley.edu!ucberkeley!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 124d48,2f0c616baeb7aa42,start
X-Google-Attributes: gid124d48,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Ramtin" <Raka1381@yahoo.com>
Newsgroups: borland.public.csharpbuilder.aspdotnet.general
Subject: Databinding to a property and SQL NULL value ?
Date: Sat, 16 Apr 2005 02:18:12 +0430
Lines: 18
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
NNTP-Posting-Host: 217.219.78.137
Message-ID: <426036cb@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1113601739 217.219.78.137 (15 Apr 2005 14:48:59 -0800)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!newshub.sdsu.edu!news-hog.berkeley.edu!ucberkeley!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail