Hierachical data binding

C

Chuck Gantz

I have an existing XML file that I read into a data set ds. The XML is
hierarchical; i.e., it looks like

<A>
<B>
<C>
<D> element1<\D>
<E> element2<\E>
<\C>
<C>
<D> element3<\D>
<E> element4<\E>
<\C>
<\B>
<\A>

I created a schema based on the XML.
A, B, and C appear as individual dataTables in the dataset. I then bind
dataTable C to a dataGridView. Elements <D> and <E> get shown properly in
the dataGridView in two rows, one per each <C>.

If I save the dataset XML (using ds.WriteXML() ), I get back the original
XML file with the correct hierachy.

Then I added a new row in the dataGridView. When I now save the dataset XML,
dataTable C is saved as its own dataTable rather than being under <C>. In
other words, the above dataset appears as
<A>
<B>
<C>
<D> element1<\D>
<E> element2<\E>
<\C>
<C>
<D> element3<\D>
<E> element4<\E>
<\C>
<\B>
<C>
<D> element3<\D>
<E> element4<\E>
</C>
<\A>

My question (finally) is how do I save the new row I put into the
dataGridView in the correct hierarchy.

Thanks.

Chuck Gantz
 

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