help populating a vb.net dataGrid with a table from XML
Posted on 2005-04-13
Hi...i just want to load a dataGrid with a table in my XML doc. i just need to know if i need to change my XML, my VB.NET code or both and how......thanks! all the details are below; if i 've forgotten anything, just ask please!
XML CODE snippet:
<character id="0" type="PC" name="Nathan Baros" realName="Craig Pierce">
<skill name="climb" level="6" />
<skill name="sit" level="10" />
<skill name="stand" level="2" />
<character id="0" type="PC" name="Todd Myres" realName="Josh">
<skill name="falldown" level="6" />
<skill name="guitar" level="6" />
VB.NET CODE snippet:
charactersDT = charactersDS.Tables("character")
when i say *charactersDT = charactersDS.Tables("character")* i can then refer to each 'character' as a row....as in *RealNameTextBox.Text = charactersDT.Rows(RowNumber).Item("realName")*
each character's stats will go into text boxes using lines just like that one. then i have a dataGrid that i'm trying to place the skills into. i can make the dataGrid display ALL of the skills for EVERY character with "Name" and "Level" columns at the top and the skills listed in the rows.....using this code:
Dim skillsDT As DataTable
skillsDT = charactersDS.Tables("skill")
DataGridView1.DataSource = skillsDT
that grabs every 'skill' for every 'character' in the XML document; however, i only want to display the skills of ONE character at a time.
is there a way that i can specify one dataTable to consist of only the 3 skills for Nathan Baros and another dataTable to consist of only the 2 skills for Todd Myres?? can i somehow specify which row(i.e. character) i want to take the skills from? (i.e. only the skills from charactersDT.Rows(RowNumber))
Note: i am using a dataListView and listing all the characters in that listView....then, when you select one character, i want that one character's skills to appear in the dataGrid.
please Help! this is driving me nuts......thanks.