I have an existing xml document with music playlist information, which is read into a GridView control in Visual Basic. I am now wanting to save any updates in the GridView to that xml document. How can I do this?
Private Sub cboUsers_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboUsers.SelectedIndexChanged
Dim songList As New XmlDocument
songList.LoadXml(s.GetPlaylist(cboUsers.SelectedItem.ToString()))
Grid.Rows.Clear()
Dim songs As XmlNodeList = songList.DocumentElement.SelectNodes("//Song")
Dim song As XmlNode
For Each song In songs
Dim artist As String = song.SelectSingleNode("artist").InnerText
Dim title As String = song.SelectSingleNode("title").InnerText
Dim length As String = song.SelectSingleNode("length").InnerText
Dim album As String = song.SelectSingleNode("album").InnerText
Dim popularity As String = song.SelectSingleNode("popularity").InnerText
Dim row() As Object = {artist, title, length, album, popularity}
Grid.Rows.Add(row) ' Add as a row in the Grid
Next
End Sub
Thanks
One approach would be to add your own Update command column
Then use the grids Updating event to do your work. You can either retrieve the new (and old) values from the
Eg
Do your update to XML then cancel the update itself
C# code examples but easily copied to VB.
Edit, added VB code as requested