"RowState" or "SetModified" are members of DataRow, instead of DataGrid.
Apparently the following codewill always workas expected:
DataTable dt = new DataTable();
dt.Columns.Add("Column1", typeof(string));
dt.Columns.Add("Column2", typeof(string));
for (int i = 0; i < 1000; i++) {
dt.Rows.Add("Test row " + i.ToString(), "Column2 value");
}
dt.AcceptChanges();
dt.Rows[0].SetModified();
dt.Rows[200].SetModified();
dt.Rows[50].SetModified();
DataTable dtChanged = dt.GetChanges(DataRowState.Modified);
MessageBox.Show(dtChanged.Rows.Count.ToString());
So if you want to track this further, you can simplify your code further and paste it here, specially on how you determine only the last altered row state is remembered.