473,698 Members | 2,203 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 2398
Raj,

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,

Cor
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
THANK YOU VERY MUCH :) Cor
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

1
3474
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..
2
2248
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
4
5879
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
2
1542
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.
12
2873
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
7
15440
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.
3
1078
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.
3
1165
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
0
1655
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 :
0
8672
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8600
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9156
Oralloy
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...
0
9021
jinu1996
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...
0
8860
tracyyun
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...
0
7712
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6518
isladogs
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...
1
3038
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
1998
bsmnconsultancy
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.