DataRowNotInTableException, DataGridView and XmDataDocument

  • Thread starter Louis-Pierre Beaumont
  • Start date
L

Louis-Pierre Beaumont

Hello!

I have an XML file that i display and edit into a DataGridView
using a schema, the classes generated from it and
XmlDataDocument.

Here comes the problem: I delete a row in the DataGridView
by pressing the "delete" keyboard key. The DataGridView fires
a RowsRemoved event that I use to save back my XML document.
I do use the WriteXml method of my schema generated class for this purpose.

But it always throws a DataRowNotInTableException. It throws it when i call
WriteXml, AcceptChanges and so on. I looked at the DataRow RowState, and
those
i did delete are in the "Detached" RowState. The DataSet.Remove method also
puts the rows in a "Detached" RowState.

How can i "really remove" the deleted rows so that i can save my XML without
getting
that annoying exception? Please help! : )


Louis-Pierre Beaumont
Software Developer
Labcal Technologies
 
L

Louis-Pierre Beaumont

Well, i found out that i must call AccepChanges after loading the data,
then call AccepChanges after deletion, then save. It solved my problem.
The RowStates are now "Deleted" instead of "Detached".
 

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