Date Pickers with Checkboxes and Modified Rows
-
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
-
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
Check the
DaraRow.DataRowState
property. Also, if you want a list with all the changes you could callDataTable.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...