Solved

Reading in XML to a datagrid, and then writing it back out again.

Posted on 2003-11-07
6
277 Views
Last Modified: 2010-05-03
I'm working on a simple app that is to read in XML files, and display them in a two-column datagrid(One column for the node name, the other for the data).

Whoever uses the app needs to be able to modify the data in the grid if they want, then press a button to write it out again.

Reading XML into a file isn't a problem, I can store the data in a node list. But for this to work, I think I need a global datagrid, and my experience in using those are next to nothing.

So, I guess my question is, does anyone have any examples of reading data into a global datagrid, then writing it back out again? General knowledge of how to use these would be welcome too, I don't have it down yet.

Any suggestions are appreciated.
0
Comment
Question by:Inward_Spiral
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
6 Comments
 

Expert Comment

by:julman_16
ID: 9704350
Are you working in ASP or Windows client?
What is your framework (.NET or Win2K and such)?
0
 

Author Comment

by:Inward_Spiral
ID: 9704367
Working out of Visual Studio .NET.

I haven't been able to get simple tables to work by themselves yet, either. Here's what I tried so far with the DataGrid:

Private Sub DataGrid1_Navigate(ByVal sender As System.Object, ByVal ne As System.Windows.Forms.NavigateEventArgs) Handles DataGrid1.Navigate

        Dim mDataTable As New DataTable

        mDataTable.Columns.Add("col1")
        mDataTable.Columns.Add("Col2")

        For i As Integer = 0 To 10
            mDataTable.Rows.Add(New String() {"Row " & i, "Data " & i})
        Next

        Me.DataGrid1.DataSource = mDataTable
    End Sub

0
 

Author Comment

by:Inward_Spiral
ID: 9714505
Okay, I've been able to feed my stuff into a datagrid now, and I can edit the information once it is displayed in the table.

Bear with me on this...how do I save the data out of the table as strings?
I figured out how to add them, but I'm not seeing exactly how they are stored.
0
 

Author Comment

by:Inward_Spiral
ID: 9724532
Alright, I figured it out. It wasn't too pretty, but it worked for what I need.
Anyone who's interested, here's how I read data into the table and into the datagrid:

    Dim mDataTable As New DataTable
    Dim NodeNames(), NodeVals() as String 'Populate the arrays with whatever you need

            mDataTable.Columns.Add("Node Name")
            mDataTable.Columns.Add("Node Value")

            For i = 0 To (NodeVals.Length - 1)
                mDataTable.Rows.Add(New String() {NodeNames(i), NodeVals(i)})
            Next

            Me.DataGrid1.DataSource = mDataTable

And to save it back out:

           Dim mData as DataTable = mDataTable
   
           For i=0 to (NodeVals.Length - 1)
                 NodeVals(i) = mData.Rows.Item(i).Item(1)
                 NodeNames(i) = mData.Rows.Item(i).Item(0)
           Next


0
 

Accepted Solution

by:
SpazMODic earned 0 total points
ID: 9755774
PAQed, with points refunded (50)

SpazMODic
EE Moderator
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

756 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