asp.net problem with dates.

Discuss all aspects of programming here.

Moderator: The Mod Squad

asp.net problem with dates.

Postby Sick_Boy » Tue Aug 09, 2005 1:09 am

i'm working on a asp.net page that connects to a access database. in the table from which the page views data from, i have a date type field in short date format. But the asp brings the values with time added. i want to get rid of times, i want only the date to be seen. but when i try

<asp:Label id="Label5" runat="server" Text='<%#
cdate(Container.DataItem("Opening")) %>' />

in my datagrid's itemtemplate, it gives the error:

Cast from type 'DBNull' to type 'Date' is not valid.

note there are empty rows in the Opening field and it's supposed to be so.

tried to use if statement to avoid converting empty rows but couldn't figure how to use conditional expressions between server tags in the body. i don't even know i it's possible.

Waiting for your opinions. thx from now...
Sick_Boy
Initiate
Initiate
 
Posts: 64
Joined: Fri Apr 11, 2003 8:23 am
Location: Turkey

Postby Sick_Boy » Tue Aug 09, 2005 2:42 am

databinder.eval(Container.DataItem,"Fieldname", "{0:d}")
does the job. stoopid me
Sick_Boy
Initiate
Initiate
 
Posts: 64
Joined: Fri Apr 11, 2003 8:23 am
Location: Turkey


Return to Programming

Who is online

Users browsing this forum: No registered users and 1 guest