G
Guest
Hi all,
I am using the windows.forms datagrid and binding 2 datagrids to 2 different DataTables from a single typed dataset. The DataTables have a parent-child 1 to many relationship. When saving the data to an XML file (using dataset.WriteXML()), it gets written incorrectly sometimes.
Basically, my XML file should look like:
<ParentTable>
<ParentCol1>stuff</ParentCol1>
<ParentCol2>stuff</ParentCol2>
<ChildTable>
<ChildCol1>stuff</ChildCol1>
<ChildCol2>stuff</ChildCol2>
</ChildTable>
</ParentTable>
instead, it looks like:
<ParentTable>
<ParentCol1>stuff</ParentCol1>
<ParentCol2>stuff</ParentCol2>
</ParentTable>
<ChildTable>
<ChildCol1>stuff</ChildCol1>
<ChildCol2>stuff</ChildCol2>
</ChildTable>
I know that this is happening because I do not put focus off of the datagrid when going to the File > Save in the Main Menu. If I enter a new row in the parent datagrid, take focus off of that row by going to another row, and coming back to the new row, then enter a new row in the child datagrid for the corresponding parent row, then take focus off of that row, the XML is written correctly.
I have tried calling EndEdit() and Select(0) methods, but still no luck. Select(0) doesn't work because it will not take focus off of a new row if it is the first row.
Any help will be greatly appreciated. I have been looking for the answer for this for weeks and am extremely frustruated!
I am using the windows.forms datagrid and binding 2 datagrids to 2 different DataTables from a single typed dataset. The DataTables have a parent-child 1 to many relationship. When saving the data to an XML file (using dataset.WriteXML()), it gets written incorrectly sometimes.
Basically, my XML file should look like:
<ParentTable>
<ParentCol1>stuff</ParentCol1>
<ParentCol2>stuff</ParentCol2>
<ChildTable>
<ChildCol1>stuff</ChildCol1>
<ChildCol2>stuff</ChildCol2>
</ChildTable>
</ParentTable>
instead, it looks like:
<ParentTable>
<ParentCol1>stuff</ParentCol1>
<ParentCol2>stuff</ParentCol2>
</ParentTable>
<ChildTable>
<ChildCol1>stuff</ChildCol1>
<ChildCol2>stuff</ChildCol2>
</ChildTable>
I know that this is happening because I do not put focus off of the datagrid when going to the File > Save in the Main Menu. If I enter a new row in the parent datagrid, take focus off of that row by going to another row, and coming back to the new row, then enter a new row in the child datagrid for the corresponding parent row, then take focus off of that row, the XML is written correctly.
I have tried calling EndEdit() and Select(0) methods, but still no luck. Select(0) doesn't work because it will not take focus off of a new row if it is the first row.
Any help will be greatly appreciated. I have been looking for the answer for this for weeks and am extremely frustruated!