rowchanged event

E

Erik Frey

Hi,

This is a half question/half gripe:

In the RowChanged event of a DataTable, if the event signals a row
addition (e.Action == DataRowAction.Add), why oh why is the DataRow added
only after the event has been fired? This is completely unintuitive, and
seems just plain wrong. It also allows for the following code:

private void DataTable_RowChanged(object sender, DataRowChangeEventArgs e)
{
if (e.Action == DataRowAction.Add) // evaluates true!
{
if (myDataTable.GetChanges() == null) // quite possibly evaluates true!
{
BecomeFrustrated();
QuitJob();
StartDeliveringPizza();
}
}
}

Erik
 
A

Andy Gaskell

I agree. I think that behavior is acceptable for for the RowChanging event,
but RowChanged indicates that the row "has been changed successfully" when
in fact it's not even in the Rows collection at that point.
 
W

William Ryan eMVP

Hi Erik:

If you're wrong about this, so am I. I've fought the same thing and if you
trap e.Action and then test for HasChanges, there's no discernable
difference between RowChanging and RowChanged. I guess it may well be
'added' but HasChanges isn't updated until the event is completed. I'm
guessing (and this is pure conjecture) that whatever tells the dataset that
it has changes isn't activated unitl the RowChanged is completed. I've
always had to resort to checked afterward but I know, this doesn't fit very
well in an event driven paradigm.

Bill

www.devbuzz.com
www.knowdotnet.com
 

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