Groups | Blog | Home
all groups > dotnet compact framework > february 2005 >

dotnet compact framework : Databinding DateTimePicker


Mike
2/28/2005 11:59:02 PM
I am trying to bind a DataTimePicker control to a DataSet but cant seem to
get it working. I am using the following code...

DateTimePicker.DataBindings.Add(New Binding("Value", dtSampleData, "Date"))

All of my other fields bind fine but when I try to bind the DateTimePicker
control I get 'Error 13 InvalidCastException'. I am binding to a Date field
that is a Date/Time datatype. Is binding the DateTimePicker even possible?
If so I would greatly appreciate any suggestions!

Thx
Ilya Tumanov [MS]
3/1/2005 10:11:10 AM
Yes, but you have to take care of handing null values in the DataSet as DTP
would not accept them.
To do so you need to implement Binding.Format Event handler. There's a
sample in VS documentation on how to do it.

Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.

[quoted text, click to view]

clorentson
3/9/2005 9:03:06 AM
Mike,

I've found that i always get errors when trying to bind to the "value"
property but can bind to the "text" property just fine.

Carl

[quoted text, click to view]
Mike
3/9/2005 9:51:12 AM
Thanks Carl,

Well, at least that didnt fire an error when loading. But, it still is not
"bound". In other words, when I navigate between my records all of my other
bound controls change. My DateTimePicker just stays at the same value?

Mike

[quoted text, click to view]
AddThis Social Bookmark Button