Link to home
Start Free TrialLog in
Avatar of cafferm
cafferm

asked on

Track Changes in Datagrid

Hi

I have a datagrid on a form which has a table containing XML data bound to it.

I would like to be able to make changes to the XML document when i user has made changes to a cell on the table.  

Please could you tell me what the best way to do this is

Thanks

Matt
Avatar of razo
razo

well if u used a dataset to bind the datagrid from an xmlfile dataset.readxml()
u can use dataset.write(xmlfilename) to update the xmlfile
Avatar of cafferm

ASKER

the update bit i'm okay with its just catching the data when the user leaves the cell in the datagrid
well if a datagrid is bound to a dataset the dataset automatically updates when a cell value is changed
Avatar of cafferm

ASKER

This is how the datagrid is formed


  Dim xmlFile As String = "..\deid.xml"
  Dim ds1 As New DataSet("DsXML")
  Dim xmlDoc As XmlDocument
  xmlDoc = New XmlDocument()
  xmlDoc.Load(xmlFile)
  Dim DataTable As New Data.DataTable("FileContents")
  Dim l As Integer

      With DataTable.Columns
        .Add("Template_id")
        .Add("Account Name")
      End With

      Dim newIt As ListViewItem
      Dim nodelist As XmlNodeList = xmlDoc.SelectNodes("/deid/deFile")
      Dim node As XmlNode

      l = -1
      For Each node In nodelist
        If node.SelectSingleNode("Template_id").InnerText = "12" Then
          l += 1
          With DataTable.Rows
            .Add(New Object() {})
            .Item(l).Item(0) = node.SelectSingleNode("Template_id").InnerText
            .Item(l).Item(1) = node.SelectSingleNode("Account_Name").InnerText
          End With
          DataTable.AcceptChanges()
        End If
      Next

      Dim GridStyle As DataGridTableStyle = New DataGridTableStyle
      ds1.Tables.Add(DataTable)

      With DataGrid1
        .DataSource = ds1.Tables(0)
        .TableStyles.Add(GridStyle)
      End With

with this the dataset (xml file) doesn't update when you make changes when you change items in the datagrid.  thats why i feel catching the cell changes would work

any ideas?

thanks
ASKER CERTIFIED SOLUTION
Avatar of Alexandre Simões
Alexandre Simões
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of cafferm

ASKER

Thanks for the guidence!

I used a add handler in the the datagrid filler function to a shared sub where I completed the task via the rowchanged!

Sometimes it just takes a point in the right direction

Thanks alot

Matt