Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problem with DateTime and NULL columns in ADO.NET
Message
General information
Forum:
ASP.NET
Category:
ADO.NET
Title:
Problem with DateTime and NULL columns in ADO.NET
Environment versions
Environment:
C# 1.1
Database:
MS SQL Server
Miscellaneous
Thread ID:
01015071
Message ID:
01015071
Views:
78
I am working on an ASP.NET project in C# where I am using the ItemBound() method of a DataGrid to get a DataRowView of the current row:
DataRowView drvPortfolio = (DataRowView)e.Item.DataItem;
One of the columns, ExitDateTime, is a SQL Server datetime column that contains some null values. The following code does not work:
DateTime exitDateTime = (DateTime)drvPortfolio["EnterPriceDateTime"];
For the rows with a null value. In that case, I get the following error:

Exception Details: System.InvalidCastException: Specified cast is not valid.

Any ideas?
Chris McCandless
Red Sky Software
Next
Reply
Map
View

Click here to load this message in the networking platform