Solved

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

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

762 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now