I have a windows app where I would like to compare the original value of the table to the value in the grid. I had written code to do this in the following manner:
int rowIndex = this.dgvReferralDistinct.CurrentRow.Index;
DataRow row = this.m_dsReferral.ReferralGroupDistinct.Rows[rowIndex];
string origRefGrouping = row["RefGroup", DataRowVersion.Original].ToString();
string origSalesRep = row["SalesRep", DataRowVersion.Original].ToString();
This code works great until a user sorts the grid. Then the indexes do not match the dataset.
What is the proper way to find the original value for comparison purposes?
Do I need to reselect the row from the database based on the key or can I add the value twice, once as viewable and changable and again where it is not visible?
Thank you in advance.