J
Jim Florence
Hello,
I've just started in ASP and I'm having a few teething problems. Initially I
tried to write out dates from the database using
<asp:Label runat="server" ID="Label6" Text='<%# Eval("ShippedDate") %>
But I got a problem with DBNull's, a kind sould told me to look at using IIF
and that sorted part of the problem. It bypassed the Nulls but didn't
actually put the text in that I'd put in the statement.This is the code
asp:Label runat="server" ID="Label10" Text='<%# IIF (Eval("ShippedDate")is
nothing,"My Text",Container.DataItem("ShippedDate")) %>' />
After more digging I changed the code to the floowing to check for dbnull
and the text finally appeared on the page.
<asp:Label runat="server" ID="Label6" Text='<%# IIF (typeof (
Eval("ShippedDate") ) is DbNull ,"No Date",Eval("ShippedDate")) %>' />
The final piece I was trying to do was convert the date to a shortdate and
used the folowing code.
<asp:Label runat="server" ID="Label6" Text='<%# IIF (typeof (
Eval("ShippedDate") ) is DbNull ,"No
Date",FormatDateTime(Eval("ShippedDate"),vbShortDate)) %>' />
This now again gives me a "Conversion from type 'DBNull' to type 'Date' is
not valid." when I run the code.
I'm now officially confused, any help gratefully recieved
Regards
Jim Florence
I've just started in ASP and I'm having a few teething problems. Initially I
tried to write out dates from the database using
<asp:Label runat="server" ID="Label6" Text='<%# Eval("ShippedDate") %>
But I got a problem with DBNull's, a kind sould told me to look at using IIF
and that sorted part of the problem. It bypassed the Nulls but didn't
actually put the text in that I'd put in the statement.This is the code
asp:Label runat="server" ID="Label10" Text='<%# IIF (Eval("ShippedDate")is
nothing,"My Text",Container.DataItem("ShippedDate")) %>' />
After more digging I changed the code to the floowing to check for dbnull
and the text finally appeared on the page.
<asp:Label runat="server" ID="Label6" Text='<%# IIF (typeof (
Eval("ShippedDate") ) is DbNull ,"No Date",Eval("ShippedDate")) %>' />
The final piece I was trying to do was convert the date to a shortdate and
used the folowing code.
<asp:Label runat="server" ID="Label6" Text='<%# IIF (typeof (
Eval("ShippedDate") ) is DbNull ,"No
Date",FormatDateTime(Eval("ShippedDate"),vbShortDate)) %>' />
This now again gives me a "Conversion from type 'DBNull' to type 'Date' is
not valid." when I run the code.
I'm now officially confused, any help gratefully recieved
Regards
Jim Florence