Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. DateTimePicker and BindingSource Problem

DateTimePicker and BindingSource Problem

Scheduled Pinned Locked Moved C#
helpquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Ahmad Safwat
    wrote on last edited by
    #1

    Hi all, I have a problem with DateTimePicker and BindingSource. The BindingSource DataSource is a DataTable of 3 Columns (ID, Name, and Date). The "ID" Field is Primary key that of cource doesn't allow nulls. Both "ID" and "Name" fields are bound to TextBoxes, and "Date" Field is bound to a DateTimePicker control. Now when I'm trying to add a new record, I got an exception of: "Column 'ID' does not allow nulls." although it has a value. when I don't bind "Date" field, problem doesn't occur Can you help meeee?? :((

    A P 2 Replies Last reply
    0
    • A Ahmad Safwat

      Hi all, I have a problem with DateTimePicker and BindingSource. The BindingSource DataSource is a DataTable of 3 Columns (ID, Name, and Date). The "ID" Field is Primary key that of cource doesn't allow nulls. Both "ID" and "Name" fields are bound to TextBoxes, and "Date" Field is bound to a DateTimePicker control. Now when I'm trying to add a new record, I got an exception of: "Column 'ID' does not allow nulls." although it has a value. when I don't bind "Date" field, problem doesn't occur Can you help meeee?? :((

      A Offline
      A Offline
      Acid_Inex
      wrote on last edited by
      #2

      Take a look http://www.devnewsgroups.net/group/microsoft.public.dotnet.framework.windowsforms/topic64486.aspx[^]

      1 Reply Last reply
      0
      • A Ahmad Safwat

        Hi all, I have a problem with DateTimePicker and BindingSource. The BindingSource DataSource is a DataTable of 3 Columns (ID, Name, and Date). The "ID" Field is Primary key that of cource doesn't allow nulls. Both "ID" and "Name" fields are bound to TextBoxes, and "Date" Field is bound to a DateTimePicker control. Now when I'm trying to add a new record, I got an exception of: "Column 'ID' does not allow nulls." although it has a value. when I don't bind "Date" field, problem doesn't occur Can you help meeee?? :((

        P Offline
        P Offline
        PeSVe
        wrote on last edited by
        #3

        Before actually adding a the new record, you should clear the datetimepicker's databinding, using the method datetimepicker1.DataBindings.Clear() in C#. After that binding the datetimepicker1 to the same data source it's bound before.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups