Results 1 to 2 of 2

Thread: DateTimePicker and Null values from database

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2009
    Posts
    17

    Unhappy DateTimePicker and Null values from database

    Hi,

    I'm having problem with DateTimePicker control in my project. My controls on winform are connected with table in database with Entity Framework model (i'm using BindingSource and BindingNavigator). All data from my table are shown properly, but DateTimePicker control makes me a real headache. Why? Because table has column with dates and null values. So, when I have a record with null date value, my DateTimePicker shows me todays date. Or when I'm navigating through my database (movefirst, movenext, etc), it just doesn't show correct values for records with null values.

    I am able to detect null value, if I put my bindingsource to DateTimePicker.Tag property instead to DateTimePicker.Value. But how should I now show my blank tag values and date values properly in DateTimePicker.Value??? I realy need some good example.

    Please help in thank in advance

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: DateTimePicker and Null values from database

    The DateTimePicker has ShowCheckBox and Checked properties to help with this. Set ShowCheckBox to true to display a check box in the control. You can then set Checked to True for a value and false for null.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width