How to Export DGV to XML

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Michael Warlich

    How to Export DGV to XML

    Hi Everybody

    i have a datagridview in VB.NET which is filled with an XML file this way:

    Code:
    Dim xmlDataDoc As New XmlDataDocument
    Dim ds As New DataSet("Book Dataset")
    
    xmlDataDoc.DataSet.ReadXml("D:\books.xml")
    ds = xmlDataDoc.DataSet
    DataGridView1.DataSource = ds.DefaultViewManager
    DataGridView1.DataMember = "Book"
    When i make Changes in the DGV, i want wo save them back to the
    XML-File. But i don't know how!

    i tried:

    Code:
    Dim DS As DataSet
    ' --- DataSet erzeugen
    DS = New System.Data.DataSet()
    DS = DataGridView1.DataSource
    DS.WriteXml("D:\ddd.xml", XmlWriteMode.WriteSchema)
    what is wrong? the problem is: i cant make a DataSet out of the dgv with
    DS = DataGridView1.D ataSource.
    What else can i do?

    Thanks
    MIchael
Working...