I have a small XML file that I want to read into a dataset. The XML file contains a sortorder node and I'd like to sort the data in the XML file using that node.
Funny thing is that the data in the DataSet does not get sorted correctly. Here's the XML file:
<?xml version="1.0" encoding="utf-8" ?>
<name>Name of Item 1</name>
<name>Name of Item 2</name>
and here's the VB
code I am using:
Dim MyDataSet As New DataSet
Dim MyDataView As DataView = MyDataSet.Tables(0).DefaultView
MyDataView.Sort = "sortorder DESC"
For Each MyDataRow As DataRow In MyDataView.Table.Rows
MessageBox.Show("Item is " & MyDataRow(0))
DataGrid1.DataSource = MyDataView
The weird thing is that the For Each loop does *not* return the items in the requested order. That is, Item 1 comes first, then Item 2.
However, the DataGrid *does* display the data in the correct order.
Is there anything I should do to retrieve the data from the DataSet in the right order using For Each or For? I know it's in there in the right order, because the DataGrid can display the data correctly....
Everyone is unique, except for me.