problems updating a date type

A

Adam Sandler

Hello,

I'm using VWD 2005 and have a grid on the page. In that grid, there's
a column that is of date/time type. Nulls are allowed in this column.
I'm having problems when trying to edit this date column.

I've converted the column to a template and changed the
EditItemTemplate from a textbox to a calendar. If a date previously
existed for the record being edited, the update action works. If the
date was previously NULL and then a date is chosen via the calendar
control, this error is thrown:

Server Error in '/Names' Application.
________________________________________
Conversion from type 'DBNull' to type 'Date' is not valid.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Conversion from type
'DBNull' to type 'Date' is not valid.

I've seen lot of solutions in my research where code fixes this. I'd
prefer to leverage the capabilities the development environment gives
me and solve it that way. Is there a property or a configuration I've
missed somewhere?

Thanks!
 
G

Guest

Adam,
you must be kidding I did not know you could do that. I'd try low value
date and treating it like a null.

DWS
 
A

Adam Sandler

DWS said:
Adam,
you must be kidding I did not know you could do that. I'd try low value
date and treating it like a null.

DWS

Nope... if the record is null then VS gives me the finger because it
doesn't know how to convert how to convert a null to a date. With a
textbox, there's no problem but with the calendar control; it's not
happy.

I was hoping there was something in the properties window, which I may
have overlooked, to keep this error from being thrown... but I guess
there's not. I ended up using a code behind solution.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top