Solved

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

Posted on 2003-11-07
6
266 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
  • 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…

770 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