DataRow, DataTable, DataGridView, avoid changing values in the DataRow

May 5 2006 2:21 PM

Hi everybody!

 

I have the next code and I’m having a problem with the DataRow:

 

DataTable dt = new DataTable();

dt.Load(GetReader());                       

dataGridView.DataSource = dt;

DataRow[]originalRows = dt.Select();

 

The problem is that when I change a cell value in the datagridview the change is also set in the originalRows values. I’d like to avoid this, since I want to use the original values of the datatable to compare them later to see whether there ware changes in my datagridview.

 

I tried the following but it didn't work:

 

private void dataGridView_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)

{

originalRows[e.RowIndex].CancelEdit();

originalRows[e.RowIndex].EndEdit();

}

 

 

Thanks in advance,

 

Elvia

 

PS: Windows application in Microsoft Visual C# 2005


Answers (1)