XML and Datagrids

K

Kevin

I want to be able to load a xml file into a datagrid on a form. From this I
want a user to be able to edit any field in the datagrid and then write
those changes back to specific elements in another xml file.

I have been able to read an xml file into the datagrid...this is no problem.

I am having trouble with once I have made the changes, writing them back out
to the other xml file.

Any help would be appreciated.
Thanks,
Kevin
 
S

Slonocode

Im doing something sort of similar. I read the xml file into a dataset,
then make appropriate changes to the dataset, and finally write the dataset
back to xml.

ds is a public dataset
Private Sub GetData()

ds.Clear()

ds.ReadXmlSchema("Calls.xml")

ds.ReadXml("Calls.xml")

End Sub



Private Sub UpdateData(ByVal name As String, ByVal number As String)

Dim dr As DataRow = ds.Tables("Call").NewRow

dr("Name") = name

dr("Number") = "(" & number.Substring(0, 3) & ") " & number.Substring(3, 3)
& "-" & number.Substring(6, 4)

dr("Date") = Now.ToString

ds.Tables("Call").Rows.Add(dr)

ds.WriteXml("Calls.xml")

End Sub
 
K

Kevin

Thanks,

that helps out somewhat but I still need help.
I need to have the user edit the datagrid, then write those changes to the
dataset
If I edit one cell in a datagrid will that automatically reflect the changes
in my dataset?
 
G

Greg

If you edit one cell, you will then have 2 DataRows, kinda sorta. One will
be marked as Original and one will be marked as Modified. The dataset will
reflect the changes, but not permanently until you either call
DataAdapter.Update or call AcceptChanges on the DataRow. A successful
update will call AcceptChanges for you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top