Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Track Changes in Datagrid

Posted on 2004-08-15
6
Medium Priority
?
209 Views
Last Modified: 2008-03-06
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
0
Comment
Question by:cafferm
  • 3
  • 2
6 Comments
 
LVL 8

Expert Comment

by:razo
ID: 11807399
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
0
 

Author Comment

by:cafferm
ID: 11807409
the update bit i'm okay with its just catching the data when the user leaves the cell in the datagrid
0
 
LVL 8

Expert Comment

by:razo
ID: 11807422
well if a datagrid is bound to a dataset the dataset automatically updates when a cell value is changed
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:cafferm
ID: 11807444
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
0
 
LVL 30

Accepted Solution

by:
Alexandre Simões earned 1000 total points
ID: 11808585
Hi...

When I need to accomplish something like this I don't bother catching the events fom the displaying controls, for 2 reasons:
1- Later on, you might (is not already) get sick of the datagrid and change it with another 3rd party grid, and you'll have to recode a lot of lines.
2- A little like above, you'll need to relly everything on the grid control... I allways try to relly the most on the core classes and use the UIControls just to Interface...

This way, again, to accomplish what you want I use the DataTable Events. yes, the datatable have events... and the really ones you need.
This way, for example, the RowChanged event, evaluate what kind of chage occurred, and proceed as you want/need.

This aproach is the one I think's the best... feel free to comment it!

Best regards,
Alex
0
 

Author Comment

by:cafferm
ID: 11849874
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
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question