processing DataTable_RowChanged event

  • Thread starter Thread starter mozek
  • Start date Start date
M

mozek

Hi,
can anyone help me with the following trouble?

PROBLEM:
There is no row with RowState=Added in DataTable during
processing RowChanged event when I try to add a new row
to a DataTable.
DESCRIPTION:
I'd like to update database as soon as any change was
made in a DataTable. I've tried to implement this
behaviour using two events: RowDeleted and RowChanged.
While RowDeleted event works fine (occurs after a DataRow
has been changed successfully), RowChanged event doesn't
in case I try to add a new row:
1/ e.Row.RowState=Added but
2/ e.Row.Table.Rows.Count=0
So the new row wasn't added to DataTable yet even thought
it has the RowState=Added!
QUESTIONS:
1/ If the new row doesn't exist in DataTable why its
RowState isn't equal to Detached?
2/ If the RowChanged event occures after a change has
been successfully made to DataTable, why the new row
doesn't exist in DataTable yet?

Thanks in advance,
mozek
 
Hi,
How are you committing your pending changes to your
DataTable? If it is by using a currency manager, you
either have move to another row or call EndCurrentEdit
BEFORE calling the DataAdapter's Update method.
Otherwise, pending changes are still being managed by the
currency manager and have not yet been committed to the
DataTable.
JT
 
Back
Top