typed DataSet not firing RowDeleted

R

Reader

Hello,

I have a typed dataset and I have the following loop.
foreach (DataTable myTable in DataStore.Tables)

{

myTable.RowChanged += new DataRowChangeEventHandler( Row_Changed );

myTable.RowDeleted += new DataRowChangeEventHandler( Row_Changed );

}



The Odd thing about this is that the program will fire the RowChanged event
perfectly but it NEVER calls the RowDeleted. I have tried it with the
RowDeleting and it does call the RowDeleting event but this is not what i
need since I cannot tell when in a child table that is activated via a
cascade to determine if the parent record was the cause of the cascade or if
the individual child record was being deleted by itself.



If there is just a way to determine if a child record's deletion is not
caused by a cascade then this would greatly help. And if it is possible to
use it in the RowDeleting since this seems to be the only RowDelet* event
that I can get working.



-Thanks
 
C

Cor Ligthert

Reader,

Not even knowing the reason, however first how did you delete the row,
because that is often the reason from row delete problems.

Cor
 
R

Reader

Row delete via pressing the "Delete" key for starters. Then tried calling
the .Delete() method on rows.
 
C

Cor Ligthert

Reader,

A row that is deleted will only be set the rowstate to "deleted" when it is
first readed from a database.
(Or there has been done an acceptchanges)

When it is created in the same routine, it the datarow will be removed and
therefore there is no rowstate.

In other words.
When the rowstate was new and it will be deleted than the row will be
removed.
When the rowstate was unchanged and the row is deleted the rowstate becomes
deleted.

Can that be the reason?

Cor
 
G

Guest

That would be why I don't do cascaded deletes, but do it myself and maintain
control.

I certainly don't want a row to be deleted unless I specifically deleted it
myself.
 
R

Reader

I think i have figured it out.... on my event being called if you try to
access data that does not exist in the "row" since it has been deleted an
exception is thrown... but nothing bubbles up to the applicatoin.. thus i
never knew i was calling or doing anything wrong.. now i have it working on
the Deleted event..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top