Hi Eduardo,
>It works fine if I change record. Dataset.Haschanges(), seems to do the same.
>But for it to work the user has to move from the record. If he makes modifications to the data and close the form, Rowset or Haschanges are not aware of the change.
>What I am trying to do is Enable a save button from my datanavigator as soon as the user modifies a field in the form.There's a little "gotcha" with this, and it's caused when the data in a row has been left in a Proposed state.
Data in a DataRow has several different versions. First, there's the original version. Then, when it's being edited, it becomes a Proposed version and once it's done being edited it becomes the Current version. Sometimes when editing, the row is left in the Proposed state and needs to be ended.
Here's a method I *always* call before I attempt to save data:
protected virtual void CommitProposedChanges(DataSet ds)
{
if (ds == null)
return;
for (int nTable = 0; nTable < ds.Tables.Count; nTable++)
{
for (int nRow = 0; nRow < ds.Tables[nTable].Rows.Count; nRow++)
{
if (ds.Tables[nTable].Rows[nRow].HasVersion(DataRowVersion.Proposed))
{
ds.Tables[nTable].Rows[nRow].EndEdit();
}
}
}
}
Without calling the above method, .HasChanges() could return a false when in fact there is a Proposed change just waiting to be committed.
~~Bonnie