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
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
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
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("FileConten ts")
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("Tem plate_id") .InnerText = "12" Then
l += 1
With DataTable.Rows
.Add(New Object() {})
.Item(l).Item(0) = node.SelectSingleNode("Tem plate_id") .InnerText
.Item(l).Item(1) = node.SelectSingleNode("Acc ount_Name" ).InnerTex t
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
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("FileConten
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/
Dim node As XmlNode
l = -1
For Each node In nodelist
If node.SelectSingleNode("Tem
l += 1
With DataTable.Rows
.Add(New Object() {})
.Item(l).Item(0) = node.SelectSingleNode("Tem
.Item(l).Item(1) = node.SelectSingleNode("Acc
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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
u can use dataset.write(xmlfilename)