Home All Groups Group Topic Archive Search About

DataRowNotInTableException, DataGridView and XmDataDocument

Author
14 Dec 2005 3:14 PM
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

Author
14 Dec 2005 4:02 PM
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".

Show quote
"Louis-Pierre Beaumont" <lpbeaumont@labcal_spamsucks.com> wrote in message
news:uXEpQEMAGHA.1600@TK2MSFTNGP11.phx.gbl...
> 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
>
>

AddThis Social Bookmark Button