Issue binding a DateTimePicker to a DataView

L

Lorenz Kahl

Hi,

when I'm trying to bind a DateTimePicker to a DataView I receive a
System.Exception when the form loads.
I don't get an error when binding it to a DataSet.Table that is
representing exactly the same data.

The error-message is in German saying:
"DataBinding konnte keine Zeile in der Liste finden, die für alle
Bindungen verwendet werden kann."

I'll try to translate that:
"DataBinding wasn't able to find a row in the list, which could be used
for all bindungs."

Any ideas?
Thanks and regards,
Lorenz
 
C

Cor Ligthert

Lorenz,

The simples part to show to make it posible to help you is the binding code
and the creating of the dataview (or did you do it using the designer)?

Cor

....
 
L

Lorenz Kahl

Hi Cor,
(or did you do it using the designer)?

yes. Is that a problem?

When I use the DataSet.Table for DataBinding the generated code looks
like this:

this.dtpValidFrom.DataBindings.Add(new
System.Windows.Forms.Binding("Value", this.dsMemberDetails,
"Member.ValidFrom"));

When I use the DataView for DataBinding the generated code looks like
this but I gat the error:

this.dtpValidFrom.DataBindings.Add(new
System.Windows.Forms.Binding("Value", this.dvMemberFilter, "ValidFrom"));

That's exactly hoe I would have coded it by hand - so I don't get it,
why it fails...?
 
C

Cor Ligthert

Lorenz,

And you did not add a rowfilter by accident in the designer in the dataview?

Cor
 
L

Lorenz Kahl

Hi Cor,
And you did not add a rowfilter by accident in the designer in the dataview?

No! Not in the designer! But I do want to apply a row filter later
programatically! But there's no filter set, when the form loads!

Will the rowFilter interfer with the DateTimePicker? I wouldn't
understand the reason why...? Maybe you could shed some light for me?
 
L

Lorenz Kahl

Lorenz said:
Hi Cor,



yes. Is that a problem?

When I use the DataSet.Table for DataBinding the generated code looks
like this:

this.dtpValidFrom.DataBindings.Add(new
System.Windows.Forms.Binding("Value", this.dsMemberDetails,
"Member.ValidFrom"));

When I use the DataView for DataBinding the generated code looks like
this but I gat the error:

this.dtpValidFrom.DataBindings.Add(new
System.Windows.Forms.Binding("Value", this.dvMemberFilter, "ValidFrom"));

That's exactly hoe I would have coded it by hand - so I don't get it,
why it fails...?

OK,

I found a way to get it to work - though I don't understand why...
As Cor implied I bound the controls manually/programatically - NOT
graphically - in the 'Form'_Load-Handler, like so:

this.dtpValidFrom.DataBindings.Add("Value", this.dvMemberFilter,
"ValidFrom");

Don't know, why this is any different from the generated code???

Make sure that you 'unbound' the DateTimePicker-control graphically
before doing so.
 

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

Top