I've spent a great deal of time researching a solution to my issue with very little success. I'm rather new with .NET and vb.net so I apologize if this seems simple to anyone else. I had a first version of what I am trying to do which worked fine. I will provide sample XML and the vb.net code I used to render it. As I decided that I needed to add an additional node to the XML file I am no longer sure how to process it.
Original XML:
<?xml version="1.0" encoding="utf-8"?>
<!--Transaction File.-->
<Transaction>
<Items>
<Item>
<ItemID>1234</ItemID>
<PriceEach>100.00</PriceEach>
<Purchased>2</Purchased>
<ItemTotal>200.00</ItemTotal>
</Item>
<Item>
<ItemID>2345</ItemID>
<PriceEach>2.50</PriceEach>
<Purchased>3</Purchased>
<ItemTotal>7.50</ItemTotal>
</Item>
</Items>
</Transaction>
Vb.net code to populate DataGridView with each item being its own row.
Dim Transaction As New DataSet
Transaction.ReadXml(TransactionID) 'TransactionID is sent to this code
DataGridView1.DataSource = Transaction.Tables(0)
This works perfectly. However, I decided that I needed to add a new node to hold the total cost for the specific transaction. So the new XML file is as such:
<?xml version="1.0" encoding="utf-8"?>
<!--Transaction File.-->
<Transaction>
<TransactionTotal>207.50</TransactionTotal>
<Items>
<Item>
<ItemID>1234</ItemID>
<PriceEach>100.00</PriceEach>
<Purchased>2</Purchased>
<ItemTotal>200.00</ItemTotal>
</Item>
<Item>
<ItemID>2345</ItemID>
<PriceEach>2.50</PriceEach>
<Purchased>3</Purchased>
<ItemTotal>7.50</ItemTotal>
</Item>
</Items>
</Transaction>
So now I have a new tagset of TransactionTotal which should be displayed as the text property of a label titled TransactionTotal. TransactionTotal.Text = ?? The TransactionTotal tags are on the same level as the Items tags. And then The DataGridView should show all of each Item within Items as a new row in the DGV.
Obviously this new node makes my original DGV populate code invalid. I use a Try/Catch statement which throws no errors because the XML file is found and it validates as proper XML but my DGV is blank as the code is thrown off by TransactionTotal being added into the mix.
I greatly appreciate any help leading me the right way!