?
Solved

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

Posted on 2003-11-07
6
Medium Priority
?
297 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying 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

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…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

649 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