Mark a DataTable dirty

  • Thread starter Thread starter David Thielen
  • Start date Start date
D

David Thielen

Hi;

How can I mark a DataTable as dirty (has changes)? I need
to do this because when I add a DataColumn to a
DataTable, it does not set HasChanges() to true.

thanks - dave
 
Hi David,

DataTable itself doen't have a dirty property.
Instead, every row has RowState property which marks the row state.
If you want to mark all rows as changed you might loop through all of them
and set one of the fields to the same value.
BTW, what are you trying to achieve?
 
I've found that when I programatically add a column - it
still returns false for HasChanges(). So in that case I
need to have a way to force HasChanges() to return true
after the column insertion.

I assume the way to handle this is do:
if (table.Row[0].DataState == DataRowState.Unchanged)
table.Row[0].DataState = DataRowState.Modified;


thanks - dave
 
That doesn't work - DataState is get only.

Any ideas how to set this?

thanks - dave

-----Original Message-----
I've found that when I programatically add a column - it
still returns false for HasChanges(). So in that case I
need to have a way to force HasChanges() to return true
after the column insertion.

I assume the way to handle this is do:
if (table.Row[0].DataState == DataRowState.Unchanged)
table.Row[0].DataState = DataRowState.Modified;


thanks - dave

-----Original Message-----
Hi David,

DataTable itself doen't have a dirty property.
Instead, every row has RowState property which marks
the
row state.
If you want to mark all rows as changed you might loop through all of them
and set one of the fields to the same value.
BTW, what are you trying to achieve?

--
Miha Markic - RightHand .NET consulting & development
miha at rthand com




.

.
 
Hi asking again...

That doesn't work - DataState is get only.

Any ideas how to set this?

thanks - dave

-----Original Message-----
I've found that when I programatically add a column - it
still returns false for HasChanges(). So in that case I
need to have a way to force HasChanges() to return true
after the column insertion.

I assume the way to handle this is do:
if (table.Row[0].DataState == DataRowState.Unchanged)
table.Row[0].DataState = DataRowState.Modified;


thanks - dave

-----Original Message-----
Hi David,

DataTable itself doen't have a dirty property.
Instead, every row has RowState property which marks
the
row state.
If you want to mark all rows as changed you might loop through all of them
and set one of the fields to the same value.
BTW, what are you trying to achieve?

--
Miha Markic - RightHand .NET consulting & development
miha at rthand com

Hi;

How can I mark a DataTable as dirty (has changes)? I need
to do this because when I add a DataColumn to a
DataTable, it does not set HasChanges() to true.

thanks - dave
 
Back
Top