PC Review


Reply
Thread Tools Rate Thread

BUG? : Databinding To DateObject Returning Invalid Date

 
 
Marauderz
Guest
Posts: n/a
 
      24th May 2004
Hi, I have an object that implements IEditableObject that exposes a Date
property.

A DateTimePicker on a form is bound to the property on the object.

But when I call BindingContext.CancelCurrentEdit on it I get an error that
says I'm trying to set an invalid date to the control a date of 01/01/0001
12:00:00AM.

Obviously something's wrong, I've stepped through the CancelEdit call on my
object, the member variables all have proper dates so I don't know how this
came to be, any suggestions?

Thanks!


 
Reply With Quote
 
 
 
 
Marauderz
Guest
Posts: n/a
 
      24th May 2004
OK, I found the problem..

It seems like at least in 1.0 of the framework, when you Databind to a
control which is NOT visible. Databinding screws up bad. Can anyone confirm
this? I already have seen this exhibited in Labels, and DateTimePickers.


"Marauderz" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi, I have an object that implements IEditableObject that exposes a Date
> property.
>
> A DateTimePicker on a form is bound to the property on the object.
>
> But when I call BindingContext.CancelCurrentEdit on it I get an error that
> says I'm trying to set an invalid date to the control a date of 01/01/0001
> 12:00:00AM.
>
> Obviously something's wrong, I've stepped through the CancelEdit call on

my
> object, the member variables all have proper dates so I don't know how

this
> came to be, any suggestions?
>
> Thanks!
>
>



 
Reply With Quote
 
Calvin Luttrell/ProjectThunder.com
Guest
Posts: n/a
 
      24th May 2004
Marauderz,

With out knowing what is going on under the hood it's difficult for me to say for sure. This property that you are binding too seems to have a valid date but I don't think the calendar control allows dates only one year after AD. When you initialize the date variable try putting a date in it as a test.

Dim Mydate as DateTime = Now


-Calvin Luttrell
ProjectThunder.com


> Hi, I have an object that implements IEditableObject that exposes a Date
> property.
>
> A DateTimePicker on a form is bound to the property on the object.
>
> But when I call BindingContext.CancelCurrentEdit on it I get an error that
> says I'm trying to set an invalid date to the control a date of 01/01/0001
> 12:00:00AM.
>
> Obviously something's wrong, I've stepped through the CancelEdit call on my
> object, the member variables all have proper dates so I don't know how this
> came to be, any suggestions?


 
Reply With Quote
 
Pete Wright
Guest
Posts: n/a
 
      24th May 2004
My gut feeling on this is that your control has code to initialize the date
and time when the control is drawn, hence the reason binding to it invisible
doesn't work. .NET usually has not problem binding to 'controls' which are
not visible providing the control's are written properly. I'm not at all
being funny here, but when I'm stuck with a problem like this one I usually
ending reading the error message very very slowly and literally. In your
case, that indicates an invalid date so check the code in the control is
initializing the date without requiring the control to be drawn.

Hope that helps some,

--
--------------------------------------------------------
Peter Wright (www.petewright.org)
Author of ADO.NET Novice To Pro
From Apress. www.apress.com


"Marauderz" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> OK, I found the problem..
>
> It seems like at least in 1.0 of the framework, when you Databind to a
> control which is NOT visible. Databinding screws up bad. Can anyone

confirm
> this? I already have seen this exhibited in Labels, and DateTimePickers.
>
>
> "Marauderz" <(E-Mail Removed)> wrote in

message
> news:(E-Mail Removed)...
> > Hi, I have an object that implements IEditableObject that exposes a Date
> > property.
> >
> > A DateTimePicker on a form is bound to the property on the object.
> >
> > But when I call BindingContext.CancelCurrentEdit on it I get an error

that
> > says I'm trying to set an invalid date to the control a date of

01/01/0001
> > 12:00:00AM.
> >
> > Obviously something's wrong, I've stepped through the CancelEdit call on

> my
> > object, the member variables all have proper dates so I don't know how

> this
> > came to be, any suggestions?
> >
> > Thanks!
> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with Socket.EndReceive Returning Invalid Value O.B. Microsoft C# .NET 2 28th Sep 2007 12:18 AM
Returning invalid use of Null error =?Utf-8?B?Yml6cHJv?= Microsoft Access Form Coding 6 24th Jul 2005 05:27 AM
Dlookup returning invalid use of Null Van T. Dinh Microsoft Access 0 15th Sep 2004 01:19 AM
Re: Dlookup returning invalid use of Null '69 Camaro Microsoft Access 1 14th Sep 2004 10:55 PM
Re: Query returning INvalid Results Tony Toews Microsoft Access 1 15th Sep 2003 12:25 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:46 PM.