Export DataGrid data to an XML File.
To export data from datagrid to XML, you can use WriteXML function.
Example :
Dim myCommand As SqlDataAdapter
myCommand = New SqlDataAdapter("Select * from student", myconn)
' declare the dataset function
Dim ds As DataSet = New DataSet()
myCommand.Fill(ds, "student")
DataGridView1.DataSource = (ds)
DataGridView1.DataSource = ds.Tables(0)
ds.WriteXml("c:\student.xml")
Download : exportXML.wmv (680.55 kb)