1,105,263 Community Members

Save datagridview to xml?

Member Avatar
DJAyzed
Newbie Poster
8 posts since Dec 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

I have a datagridview on my form called "mainGrid" and im not very good with XML buti found a small example to load but not one to save
I wondered if there was a equally simple way to save! Heres the loading code:

Private Sub loadGrid()
        Dim ds As DataSet = New DataSet
        ds.ReadXml("C:\x\tsst.xml")
        Dim dv As DataView = New DataView(ds.Tables(0))
        mainGrid.DataSource = dv
End Sub

as you can see it is very simple and i didnot have to manually do anything i was wondering if it was the same for saving or if not how i could do it thanks
any questions etc. just ask i will reply!

Member Avatar
__avd
Posting Genius (adatapost)
6,703 posts since Oct 2008
Reputation Points: 1,811 [?]
Q&As Helped to Solve: 1,272 [?]
Skill Endorsements: 61 [?]
Moderator
 
0
 

>I wondered if there was a equally simple way to save![/d]

...
ds.WriteXml("filename.xml");
// OR
ds.Tables["tableName"].WriteXml("filename.xml");
 ...
Member Avatar
DJAyzed
Newbie Poster
8 posts since Dec 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

I had tried this, but im pretty sure that it would just write the code from the original file since ds is not bound to the datagridview?
Im sorry, i dont know much about XML how would you bind the dataset to the gridview?

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: