473,722 Members | 2,218 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Datagrid - ReadXml

I am trying to read an xml file and have it view data in the datagrid. (For
example take the xml file viewer in the visual studio, when u open an xml
file it has that nice readable grid).

I though that when i use the ReadXml funtion it will automatically read data
and add the data to the datagrid.

but i am wrong its not that simple. so i need help only with adding the data
to the datagrid.
this is what i have so far. I have created the grid with coulum names now i
need to add the rows of data. please help me :) thanks
private void CreateDataSet(s tring fileName)


DataSet newDataSet = new DataSet("New Data Set");

System.IO.FileS tream readXml = new
System.IO.FileS tream(fileName, System.IO.FileM ode.Open);

newDataSet.Read Xml(readXml);

readXml.Close() ;

DataTable myTable = new DataTable("Myta ble");

DataColumn cl1 = new DataColumn("Dat e");

DataColumn cl2 = new DataColumn("Dev ice");

DataColumn cl3 = new DataColumn("cal l id");

DataColumn cl4 = new DataColumn("sou rce");

DataColumn cl5 = new DataColumn("des tination");

myTable.Columns .Add(cl1);

myTable.Columns .Add(cl2);

myTable.Columns .Add(cl3);

myTable.Columns .Add(cl4);

myTable.Columns .Add(cl5);
////////////// ADD ROWS HERE??????????////////

newDataSet.Tabl es.Add(myTable) ;
dataGrid1.SetDa taBinding(newDa taSet,"Mytable" );

Nov 17 '05 #1
3 2399

This does probably what you want.
private void CreateDataSet(s tring fileName)
DataSet newDataSet = new DataSet();
newDataSet.Read Xml("FullPath") ;
dataGrid1.DataS ource = newDataSet.Tabl es[0];

I hope this helps,

Nov 17 '05 #2
Oeps, I did not see you where passing the path
private void CreateDataSet(s tring fileName)
DataSet newDataSet = new DataSet();
newDataSet.Read Xml(fileName);
dataGrid1.DataS ource = newDataSet.Tabl es[0];
Nov 17 '05 #3
it works :)

"Cor Ligthert [MVP]" <no************ @planet.nl> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
Oeps, I did not see you where passing the path
private void CreateDataSet(s tring fileName)
DataSet newDataSet = new DataSet();
newDataSet.Read Xml(fileName);
dataGrid1.DataS ource = newDataSet.Tabl es[0];

Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Mike Dole | last post by:
Why is it that when I want to use an attribute like for instance: .WriteAttributeString("WaiterId", "14") and later on (in another application) want to bind the xml to a datagrid with readxml I'm not getting any records (just one row with 14 in it..) If I ommit the attribute it works just fine? What am I doing wrong here, have to admit I'm more or less discovering xml..
by: Frosty | last post by:
Howto make datagrid enforce rules of xml schema? Created xml schema in the designer. Constraints created there using the following <xs:simpleType name="zipcode"><xs:restriction base="xs:string"><xs:pattern value="\d{5}" /></xs:restriction></xs:simpleType Datagrid does not enforce this rule, even though dataGrid1_Validating() is called. dataset.WriteXml() saves withouth any warning, but
by: Jussi | last post by:
I load a XML document in the DataGrid: private System.Windows.Forms.DataGrid myDataGrid = new DataGrid(); private DataSet m_myDataSet = new DataSet(); m_myDataSet.ReadXml(@"C:\...\MyDocument.xml"); myDataGrid.DataSource = m_myDataSet; This works fine and user can edit the loaded document. The problem is that I don't want to give possibility to change the structure of the
by: scott | last post by:
Hi all First off, thank you for any one that can help. I have a problem trying to link a DataGrideTableStyle to a DataGrid. I have a dataset which reads from a file a xml schema and a xml file. This is done using the ReadXmlSchema and ReadXml. I then create a DataTable to get access to the tables in the data set.
by: James Norton-Jones | last post by:
Hi, Am I trying to hold the data of a DataGrid in a label so that when the form is reposted the DataGrid can be repopulated. The problem I am having is that I don't understand how to get the text into a stream in order to be able to use DataSetOutcomes1.ReadXML(MyStream). Thanks in advance, James
by: Juan Romero | last post by:
Hey guys, please HELP I am going nuts with the datagrid control. I cannot get the damn control to refresh. I am using soap to get information from a web service. I have an XML writer output the file to a folder, and then I read it back into the dataset using the dataset1.readxml. Up to this point, everything works wonderfully. The query executes, the dataset gets populated, and I get the results displayed in the datagrid.
by: Rodi Roberto | last post by:
Hi all, i have a problem on a datagrid (webforms), i don't know if is a problem on my code, if is a bug of DataGrid or simply if is normal... When i add a node on a datagrid or when i delete a node, all works fine, but at this moment if you press F5 to refresh the page, my application continue to add node(if i added a node) or to delete a node (if i deleted a node). What's happens? Thank you all , and scuse me for my bas english.
by: Darin | last post by:
I can get an XML loaded into a datagrid using: Dim ds As New DataSet ds.ReadXml("jp.xml") gData.DataSource = ds But, this a grid that allows clicking on the plus to see styles, alignment, etc. I want to load it in a datagrid so it appears in rows and columns just
by: webaccess | last post by:
Hi Friends ..!! I want to use datagrid/dataview control to data in tablular format,also I want to add paging and format the data of table column. Problem is data is coming from API Dom in as XML source. Now to display data i hv use dataset to fetch data.so i m displaying data in datagrid/dataview. Now here comes a problem: Using Datagrid :
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.