473,503 Members | 1,662 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problems updating a date type

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!

May 11 '06 #1
2 1227
DWS
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
"Adam Sandler" wrote:
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!

May 14 '06 #2

DWS wrote:
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.

May 15 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2943
by: | last post by:
Hello, Sorry to ask what is probably a simple answer, but I am having problems updating a table/database from a PHP/ PHTML file. I can Read From the Table, I can Insert into Table/Database, But...
2
1652
by: m | last post by:
hi all, got an interesting problem: im working with purchase orders and in detail line i have a date field. so for example: header line: PO code: X123 PO value: ...
19
2951
by: Dales | last post by:
I have a custom control that builds what we refer to as "Formlets" around some content in a page. These are basically content "wrapper" sections that are tables that have a colored header and...
5
2013
by: junglist | last post by:
Hi guys, I've been trying to implement an editable datagrid and i have been succesful up to the point where i can update my datagrid row by row. However what used to happen was that once i updated...
14
2912
by: el_sid | last post by:
Our developers have experienced a problem with updating Web References in Visual Studio.NET 2003. Normally, when a web service class (.asmx) is created, updating the Web Reference will...
18
2894
JamesDC
by: JamesDC | last post by:
Hi, So I'm working with an Access 2002 database for waste managemnt. The person in my role before my put together the program before he left and now I'm in charge of it. After updating a few...
4
8735
by: =?Utf-8?B?QmFyYmFyYSBBbGRlcnRvbg==?= | last post by:
I setup a simple gridview as a utility just to do some updates, nothing fancy just wanted easy UI to make updates. When I select ‘Edit’, I get the fields I want to edit. I edit them and click...
2
3548
by: rustyc | last post by:
Well, here's my first post in this forum (other than saying 'HI' over in the hi forum ;-) As I said over there: ... for a little side project at home, I'm writing a ham radio web site in...
9
4974
by: Marianne160 | last post by:
Hi, I know there are various answers to this problem available on the web but none of them seem to work for me. I am using Access 2003 to make a form to look up data from a table. I have so far...
0
7083
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7328
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6988
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5578
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5011
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3153
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1510
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
734
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.