1
Reply

How to sort the xml in datatable?

James Looi

James Looi

Feb 23 2012 12:00 PM
1.5k
Hi

I have xml file and try to load into datagridview, how can I save the xml after I sort it by desc?

Private Sub frmTesting_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
DS.ReadXml(Application.StartupPath & "\user.xml")
        Dim DS As New DataSet
        If DS.Tables(0).Rows.Count = 0 Then
            MsgBox("nothing")
        Else
            Dim i As Integer = 0
            For Each r As DataRow In DS.Tables(0).Rows
                dtgUser.Rows.Insert(i, r("ID"), r("Name"))
                i = i + 1
            Next
        End If
        dtgUser.Sort(dtgUser.Columns("ID"), System.ComponentModel.ListSortDirection.Ascending)
   End Sub


Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
           
        DS.WriteXml(Application.StartupPath & "\user.xml")
            
    End Sub

Answers (1)