While making your row-level edits, ADO.NET keeps track of the original and proposed versions of all fields. It also monitors which rows have been added to or deleted from the table, and can revert to the original row values if necessary. The Framework accomplishes this by managing various state fields for each row. The main tracking field is the DataRow.RowState property, which uses the following enumerated values:
■■ DataRowState.Detached The default state for any row that has not yet been added to a DataTable.
■■ DataRowState.Added This is the state for rows added to a table when changes to the table have not yet been confirmed. If you use the RejectChanges method on the table, any added rows will be removed immediately.
■■ DataRowState.Unchanged The default state for any row that already appears in a table, but has not been changed since the last call to AcceptChanges. New rows created with the NewRow method use this state.
■■ DataRowState.Deleted Deleted rows aren’t actually removed from the table until you call AcceptChanges. Instead, they are marked for deletion with this state setting. See the following discussion for the difference between “deleted” and “removed” rows.
■■ DataRowState.Modified Any row that has had its fields changed in any way is marked as modified.