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
  1. Home
  2. General Programming
  3. C#
  4. Date Pickers with Checkboxes and Modified Rows

Date Pickers with Checkboxes and Modified Rows

Scheduled Pinned Locked Moved C#
questiondatabasedebugging
2 Posts 2 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.
  • G Offline
    G Offline
    gmhanna
    wrote on last edited by
    #1

    Hi, I'm going to try to explain this the best I can. I have a SQL table that contains a datetime field that I am using a date picker control. This field is a verification date field for the last time the information was verified. This field can also be null if the data has not been verified. I am using a checkbox on the date picker so if the information has been verified it is checked, unverified not checked. Since SQL has no concept of this checkbox, I have written some code that works almost perfect. It gets the current row like this:

    var currentRow =
    ((myDataSet.ReunionRow)(((DataRowView)
    (myBindingSource.Current)).Row));

    and then sets the checkbox accordingly like this:

       if (currentRow.IsVerifiedNull())
            {
                verifiedDateTimePicker.Value = DateTime.Today;
                verifiedDateTimePicker.Checked = false;
                Debug.WriteLine("Verified is null");
            }
            else
            {
                verifiedDateTimePicker.Value = currentRow.Verified;
                verifiedDateTimePicker.Checked = true;
            }
    

    So far so good, you can navigate through the data forwards/backwards everything looks great. Then the user decides to change the verified information and doesn't click the save button on the navigator bar, scrolls away from this row and eventually comes back to it. My code happily gets the old data! So my question is how can I tell if this row is modified to skip this logic, or how can I get the modified row? Thank you,

    Glenn

    S 1 Reply Last reply
    0
    • G gmhanna

      Hi, I'm going to try to explain this the best I can. I have a SQL table that contains a datetime field that I am using a date picker control. This field is a verification date field for the last time the information was verified. This field can also be null if the data has not been verified. I am using a checkbox on the date picker so if the information has been verified it is checked, unverified not checked. Since SQL has no concept of this checkbox, I have written some code that works almost perfect. It gets the current row like this:

      var currentRow =
      ((myDataSet.ReunionRow)(((DataRowView)
      (myBindingSource.Current)).Row));

      and then sets the checkbox accordingly like this:

         if (currentRow.IsVerifiedNull())
              {
                  verifiedDateTimePicker.Value = DateTime.Today;
                  verifiedDateTimePicker.Checked = false;
                  Debug.WriteLine("Verified is null");
              }
              else
              {
                  verifiedDateTimePicker.Value = currentRow.Verified;
                  verifiedDateTimePicker.Checked = true;
              }
      

      So far so good, you can navigate through the data forwards/backwards everything looks great. Then the user decides to change the verified information and doesn't click the save button on the navigator bar, scrolls away from this row and eventually comes back to it. My code happily gets the old data! So my question is how can I tell if this row is modified to skip this logic, or how can I get the modified row? Thank you,

      Glenn

      S Offline
      S Offline
      Stanciu Vlad
      wrote on last edited by
      #2

      Check the DaraRow.DataRowState property. Also, if you want a list with all the changes you could call DataTable.GetChanges. Check MSDN for those properties. Note that those properties are not static, they must be called upon an instance.

      I have no smart signature yet...

      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