Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Displaying XML Files in a Data Grid

Displaying XML Files in a Data Grid

Scheduled Pinned Locked Moved C#
helpcsharpcssxml
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    soloforce
    wrote on last edited by
    #1

    As I am new to C# programming I was wondering if you could help me. Attached is a xml file that I am simple trying to display in a grid control on a Windows form program. Unfortunately I keep getting the following error An unhandled exception of type 'System.ArgumentException' occurred in system.windows.forms.dll Additional information: Cannot create a child list for field fegdata. Here is the code im using when a button is clicked. DataSet dsFeg = new DataSet("fegdata"); string filepath = "C:\\FegData.xml"; dsFeg.ReadXml(filepath); dataGrid1.DataSource = dsFeg.Tables[0]; dataGrid1.DataMember = "fegdata"; dataGrid1.CaptionText = dataGrid1.DataMember; Any help would be greatly appreciated. Peter

    H 1 Reply Last reply
    0
    • S soloforce

      As I am new to C# programming I was wondering if you could help me. Attached is a xml file that I am simple trying to display in a grid control on a Windows form program. Unfortunately I keep getting the following error An unhandled exception of type 'System.ArgumentException' occurred in system.windows.forms.dll Additional information: Cannot create a child list for field fegdata. Here is the code im using when a button is clicked. DataSet dsFeg = new DataSet("fegdata"); string filepath = "C:\\FegData.xml"; dsFeg.ReadXml(filepath); dataGrid1.DataSource = dsFeg.Tables[0]; dataGrid1.DataMember = "fegdata"; dataGrid1.CaptionText = dataGrid1.DataMember; Any help would be greatly appreciated. Peter

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      Do the following instead, as you have your DataSource set to the table and the DataMember referencing the DataSet name (completely backward):

      DataSet ds = new DataSet("fegdata");
      ds.ReadXml(@"C:\FegData.xml");
      dataGrid1.DataMember = "tableName"; // replace with appropriate table name.
      dataGrid1.DataSource = ds;
      dataGrid1.CaptionText = ds.DataSetName;

      -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups