So ever since I introduced the concept of “nullability” for the CalendarPopup and TimePicker controls, everyone has continuously asked the same basic question:
“Why is it when I try to bind my data source to SelectedDate, I get the error ‘The type DBNull cannot be converted to the type DateTime’? How can I bind it to this field?”
So the answer is, well you have to make a method call to see if the value is NULL, and return DateTime.MinValue instead. Wow, it seems so simple – this is where I believe the design flaw comes in…if it’s so darn simple, why do I keep getting asked the same question?
So, obviously, with the advancements in .NET 2.0, and the introduction of Nullable<T>, I have the opportunity to nick this in the butt so I don’t have to field this question so often. However, this would require a huge breaking change from the current version to Server Controls v2.0 in the sense that SelectedDate / SelectedTime would now become Nullable<DateTime>.
Now, if you know your CLR internals well enough, typeof(Nullable<DateTime>) != typeof(DateTime). This means that existing code where you could do .SelectedDate.ToShortDateString() no longer “just works” because you have to take it 1 step further: .SelectedDate.Value.ToShortDateString().
So, being that I develop the controls for the community, how big of a hit would it be if modifying the current signature of SelectedDate / SelectedTime to be Nullable<DateTime>? Let me know by utilizing the comment’s feature to leave your vote. Thanks, and I appreciate your honesty.
Are you living under a rock? No? Did you see that Excentrics World Server Controls v2.0, RC1 is out in public? Check it out!
566abb2a-e102-4b34-801c-a14aaefa2c3c|0|.0