PC Review


Reply
Thread Tools Rate Thread

binding nullable property

 
 
Marka83
Guest
Posts: n/a
 
      19th Dec 2007
I'm creating custom datetimepicker with nullable<datetime> property Value.
When I bind this control

Binding b = new Binding("Value", source, "some nullable property");
DatePicker.DataBindings.Add(b);

and start application it throws this exception

Invalid cast from 'System.DateTime' to 'System.Nullable`1[[System.DateTime,
mscorlib, Version=2.0.0.0, Culture=neutral ...

I've tried to define format() and parse() but it's of no use.

In this example i've used visual studio 2008 and source is result of linq to
sql query
 
Reply With Quote
 
 
 
 
Marka83
Guest
Posts: n/a
 
      20th Dec 2007


"Marka83" wrote:

> I'm creating custom datetimepicker with nullable<datetime> property Value.
> When I bind this control
>
> Binding b = new Binding("Value", source, "some nullable property");
> DatePicker.DataBindings.Add(b);
>
> and start application it throws this exception
>
> Invalid cast from 'System.DateTime' to 'System.Nullable`1[[System.DateTime,
> mscorlib, Version=2.0.0.0, Culture=neutral ...
>
> I've tried to define format() and parse() but it's of no use.
>
> In this example i've used visual studio 2008 and source is result of linq to
> sql query


My mistake.
I didn't set b.FormattingEnabled = true;
 
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
help: datetimepicker nullable required with binding support Alcibiade Microsoft C# .NET 0 21st Sep 2010 11:38 AM
Binding three state checkbox to nullable boolean klachemin@comcast.net Microsoft VB .NET 2 22nd Mar 2008 11:44 PM
Binding to Nullable(Of T) properties Jack Jackson Microsoft Dot NET Framework Forms 9 7th Feb 2008 07:36 AM
set a nullable property in object Rick Microsoft VB .NET 2 4th Jun 2007 09:09 PM
Binding nullable value to combobox Bob Rundle Microsoft ADO .NET 2 25th Aug 2004 11:22 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:19 PM.