Issue binding a DateTimePicker to a DataView

  • Thread starter Thread starter Lorenz Kahl
  • Start date Start date
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
 
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

....
 
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...?
 
Lorenz,

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

Cor
 
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?
 
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.
 
Back
Top