|
-
Feb 23rd, 2012, 12:30 PM
#3
Thread Starter
New Member
Re: How to sort dataset and save as xml
 Originally Posted by MattP
In the example code you've given DS is out of scope in the btnAdd_Click method. You'll want to sort the DataTable's DefaultView and then write the xml out.
Hand written so there may be some syntax errors.
Code:
DS.Tables(0).DefaultView.Sort = "ID ASC"
Dim outputDataTable = DS.Tables(0).DefaultView.ToTable()
outputDataTable.WriteXml("c:\blah\user.xml")
But when I select the row after I sort, the selected row data show in textbox is different from datagridview
Private Sub dtgUser_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles dtgUser.SelectionChanged
Try
Dim rows As DataRow = DS.Tables(0).Rows(dtgUser.CurrentRow.Index)
ID.Text = rows("ID")
name.Text = rows("Name")
Catch ex As Exception
End Try
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|