473,396 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

DateTimePicker & Databinding

Is there a cure for the problems using databinding with a DateTimePicker?

I find that a) sometimes it works, sometimes it doesn't, and b) it fails
silently causing all databinding on the DataSet to fail with a error message.

Help!
Nov 17 '05 #1
6 6706
See my article of January 2005 from http://pages.videotron.com/emoreau/

--
HTH

Éric Moreau, MCSD, Visual Developer - Visual Basic MVP
(http://aspnet2.com/mvp.ashx?EricMoreau)
Conseiller Principal / Senior Consultant
Concept S2i inc. (www.s2i.com)
http://pages.videotron.com/emoreau/

"eye5600" <ey*****@discussions.microsoft.com> wrote in message
news:97**********************************@microsof t.com...
Is there a cure for the problems using databinding with a DateTimePicker?

I find that a) sometimes it works, sometimes it doesn't, and b) it fails
silently causing all databinding on the DataSet to fail with a error
message.

Help!

Nov 17 '05 #2
An interesting article, but it does not answer the question of why
databinding on the form fails when the datetimepicker has binding set, but
works when the binding is removed. None of the database fields are null, by
the way.

"Eric Moreau" wrote:
See my article of January 2005 from http://pages.videotron.com/emoreau/

--
HTH

Éric Moreau, MCSD, Visual Developer - Visual Basic MVP
(http://aspnet2.com/mvp.ashx?EricMoreau)
Conseiller Principal / Senior Consultant
Concept S2i inc. (www.s2i.com)
http://pages.videotron.com/emoreau/

"eye5600" <ey*****@discussions.microsoft.com> wrote in message
news:97**********************************@microsof t.com...
Is there a cure for the problems using databinding with a DateTimePicker?

I find that a) sometimes it works, sometimes it doesn't, and b) it fails
silently causing all databinding on the DataSet to fail with a error
message.

Help!


Nov 17 '05 #3
Hi

One of my sample is bound and it is working. It has to be something you did.

Is your field defined as a date field ?

--
HTH

Éric Moreau, MCSD, Visual Developer - Visual Basic MVP
(http://aspnet2.com/mvp.ashx?EricMoreau)
Conseiller Principal / Senior Consultant
Concept S2i inc. (www.s2i.com)
http://pages.videotron.com/emoreau/

"eye5600" <ey*****@discussions.microsoft.com> wrote in message
news:E8**********************************@microsof t.com...
An interesting article, but it does not answer the question of why
databinding on the form fails when the datetimepicker has binding set, but
works when the binding is removed. None of the database fields are null,
by
the way.

"Eric Moreau" wrote:
See my article of January 2005 from http://pages.videotron.com/emoreau/

--
HTH

Éric Moreau, MCSD, Visual Developer - Visual Basic MVP
(http://aspnet2.com/mvp.ashx?EricMoreau)
Conseiller Principal / Senior Consultant
Concept S2i inc. (www.s2i.com)
http://pages.videotron.com/emoreau/

"eye5600" <ey*****@discussions.microsoft.com> wrote in message
news:97**********************************@microsof t.com...
> Is there a cure for the problems using databinding with a
> DateTimePicker?
>
> I find that a) sometimes it works, sometimes it doesn't, and b) it
> fails
> silently causing all databinding on the DataSet to fail with a error
> message.
>
> Help!


Nov 17 '05 #4
> One of my sample is bound and it is working. It has to be something you did.
Is your field defined as a date field ?


Thank you for your interest. In fact, it work fine when first developed. I
then worked on other aspects of the program, and when I returned to this
form, it no longer worked. The field I am using for illustration is birthdate
(named "birth") which is a datetime in the SqlServer database running on my
laptop. There are no nulls in this column in the database. In fact, I made
the field non-nullable, and re-created the DataSet.

Let me throw in all the info.

The DateTimePicker is configured by the following lines created by the IDE.

//
// dtpBirth
//
this.dtpBirth.Format = System.Windows.Forms.DateTimePickerFormat.Short;
this.dtpBirth.Location = new System.Drawing.Point(176, 112);
this.dtpBirth.Name = "dtpBirth";
this.dtpBirth.Size = new System.Drawing.Size(152, 27);
this.dtpBirth.TabIndex = 2;

For debuggin purposes, I moved the databinding to the bottom of the
constructor:

Binding b = new System.Windows.Forms.Binding("Value",
this.dsRmaAcct1, "rma_account.birth") ;
b.Format += new ConvertEventHandler(dtpFormatter) ;
b.Parse += new ConvertEventHandler(dtpParser) ;
this.dtpBirth.DataBindings.Add(b);

The eventhandlers were added for debugging purposes. If I include these
lines, the databinding fails for all controls bound to the same DataTable,
but binding works for controls bound to another table in the same DataSet.
By "fails", I mean that the data from the database is not displayed in the
controls when the record is created in the DataTable. I've checked that the
data is there, the row to display is correct, etc. Attempts to display the
data via CurrencyManager refresh have not helped. The Format event handler is
NOT called. (I changed the above lines to a different contol to test that
they are created properly.) I get the same effects using any of the datetime
fields, so "birth" is not unique.

The DataTable is created in the dataset by the following from the
IDE-created XML:

<xs:element name="rma_account">
<xs:complexType>
<xs:sequence>
<xs:element name="plan_id" type="xs:string" minOccurs="0" />
<xs:element name="rma_account" type="xs:string" />
<xs:element name="ssn" type="xs:string" />
<xs:element name="first" type="xs:string" minOccurs="0" />
<xs:element name="mi" type="xs:string" minOccurs="0" />
<xs:element name="last" type="xs:string" minOccurs="0" />
<xs:element name="addr1" type="xs:string" minOccurs="0" />
<xs:element name="addr2" type="xs:string" minOccurs="0" />
<xs:element name="city" type="xs:string" minOccurs="0" />
<xs:element name="state" type="xs:string" minOccurs="0" />
<xs:element name="zipcode" type="xs:string" minOccurs="0" />
<xs:element name="phone" type="xs:string" minOccurs="0" />
<xs:element name="country" type="xs:string" minOccurs="0" />
<xs:element name="birth" type="xs:dateTime" />
<xs:element name="sex" type="xs:string" minOccurs="0" />
<xs:element name="eff_dt" type="xs:dateTime" minOccurs="0" />
<xs:element name="can_dt" type="xs:dateTime" minOccurs="0" />
<xs:element name="init_amt" type="xs:decimal" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>

I found one other post on the board from someone with the same problem, but
did not get any replies. In my case, the workaround is pretty easy, but the
program is supposed to work, damn it.
Nov 17 '05 #5
You have set the Format property of your control to Short. Do you need the
Parse and Format event handlers? If you are using them, I think you would be
better using a Custom format.

--
HTH

Éric Moreau, MCSD, Visual Developer - Visual Basic MVP
(http://aspnet2.com/mvp.ashx?EricMoreau)
Conseiller Principal / Senior Consultant
Concept S2i inc. (www.s2i.com)
http://pages.videotron.com/emoreau/

"eye5600" <ey*****@discussions.microsoft.com> wrote in message
news:93**********************************@microsof t.com...
One of my sample is bound and it is working. It has to be something you
did.
Is your field defined as a date field ?


Thank you for your interest. In fact, it work fine when first developed. I
then worked on other aspects of the program, and when I returned to this
form, it no longer worked. The field I am using for illustration is
birthdate
(named "birth") which is a datetime in the SqlServer database running on
my
laptop. There are no nulls in this column in the database. In fact, I made
the field non-nullable, and re-created the DataSet.

Let me throw in all the info.

The DateTimePicker is configured by the following lines created by the
IDE.

//
// dtpBirth
//
this.dtpBirth.Format = System.Windows.Forms.DateTimePickerFormat.Short;
this.dtpBirth.Location = new System.Drawing.Point(176, 112);
this.dtpBirth.Name = "dtpBirth";
this.dtpBirth.Size = new System.Drawing.Size(152, 27);
this.dtpBirth.TabIndex = 2;

For debuggin purposes, I moved the databinding to the bottom of the
constructor:

Binding b = new System.Windows.Forms.Binding("Value",
this.dsRmaAcct1, "rma_account.birth") ;
b.Format += new ConvertEventHandler(dtpFormatter) ;
b.Parse += new ConvertEventHandler(dtpParser) ;
this.dtpBirth.DataBindings.Add(b);

The eventhandlers were added for debugging purposes. If I include these
lines, the databinding fails for all controls bound to the same DataTable,
but binding works for controls bound to another table in the same DataSet.
By "fails", I mean that the data from the database is not displayed in the
controls when the record is created in the DataTable. I've checked that
the
data is there, the row to display is correct, etc. Attempts to display the
data via CurrencyManager refresh have not helped. The Format event handler
is
NOT called. (I changed the above lines to a different contol to test that
they are created properly.) I get the same effects using any of the
datetime
fields, so "birth" is not unique.

The DataTable is created in the dataset by the following from the
IDE-created XML:

<xs:element name="rma_account">
<xs:complexType>
<xs:sequence>
<xs:element name="plan_id" type="xs:string" minOccurs="0" />
<xs:element name="rma_account" type="xs:string" />
<xs:element name="ssn" type="xs:string" />
<xs:element name="first" type="xs:string" minOccurs="0" />
<xs:element name="mi" type="xs:string" minOccurs="0" />
<xs:element name="last" type="xs:string" minOccurs="0" />
<xs:element name="addr1" type="xs:string" minOccurs="0" />
<xs:element name="addr2" type="xs:string" minOccurs="0" />
<xs:element name="city" type="xs:string" minOccurs="0" />
<xs:element name="state" type="xs:string" minOccurs="0" />
<xs:element name="zipcode" type="xs:string" minOccurs="0" />
<xs:element name="phone" type="xs:string" minOccurs="0" />
<xs:element name="country" type="xs:string" minOccurs="0" />
<xs:element name="birth" type="xs:dateTime" />
<xs:element name="sex" type="xs:string" minOccurs="0" />
<xs:element name="eff_dt" type="xs:dateTime" minOccurs="0" />
<xs:element name="can_dt" type="xs:dateTime" minOccurs="0" />
<xs:element name="init_amt" type="xs:decimal" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>

I found one other post on the board from someone with the same problem,
but
did not get any replies. In my case, the workaround is pretty easy, but
the
program is supposed to work, damn it.


Nov 17 '05 #6
> You have set the Format property of your control to Short. Do you need the
Parse and Format event handlers? If you are using them, I think you would be
better using a Custom format.


The event handlers were added only for debugging. Nothing changes when they
are removed. They do not execute, or have any noticeable effect. The changing
the Format between Long & Short has no effect on the binding problem.
Nov 17 '05 #7

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

Similar topics

0
by: Gary Miller | last post by:
I have a DateTimePicker field and it is has a DataBinding to my dataset through the Text parameter. Why is it that if I do not choose a date that the information does not get propagated to the...
9
by: Guy | last post by:
I have extended the datetimepicker control to incorporate a ReadOnly property. I have used the new keyword to implement my own version of the value property, so that if readonly == true then it...
0
by: Uchiha Jax | last post by:
When using a strongly typed dataset (generated from the Visual Studio IDE from an XSD file) and databinding I get a really odd error when binding to both a combox and a datetimepicker. I bind...
1
by: Vik | last post by:
Concatenation operator & used in the databinding expressions for the datagrid template columns appears as '&amp;' in HTML. It causes an error when opening the pages. I have to replace '&amp;' by '&' each...
2
by: Austin T | last post by:
I have a datetimepicker called say mydteTimePicker and it is bound to a dataset. However the the dataset value is null the datetimepicker displays today's date as the default. I would like it to...
7
by: Pieter | last post by:
Hi, I'm looking for a DateTimePicker that supports 100% databinding (and support null-values)... It's a shame that the normal control doesn't, but when searching on the internet, I didn't find...
1
by: Kevin | last post by:
I have put a VS2005 sample project up here: http://www.kevinandkiran.com/CSharpApplication.zip (its only 50k) Basically I have a class that contains a date property, which is initialised to...
6
by: Kyote | last post by:
I'm using a DateTimePicker for date fields in an Access db Membership app. Some of the date fields are empty, meaning they haven't been filled out yet, or they cannot be. But when a record is read...
0
by: AboutJAV | last post by:
Hi, I am using a DateTimePicker control to allow the user to select a new date. At first, I use an event Date_Changed Event as well as databinding the control to a property. When the user click...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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
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...
0
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...

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.