A step by step tutorial teaching you how to create your own chat client and chat server easily in C#, for local networks or the Internet.
A C# tutorial showing you how to make use of WMI to extract information on disk drives, such as model, capacity, sectors and serial number.
This tutorial will teach you how to calculate the shipping cost based on the weight, height, length and depth of the box, the distance and the UPS service type.
Binding a DataGrid to an XML file
This tutorial will show you how to bind a DataGrid to a simple XML file so you can display the values as rows and the tags as columns.
On Tuesday, November 2nd 2004 at 09:32 AM
By Andrew Pociu (View Profile)
(Rated 4.3 with 31 votes)
Now that it is added to the project, open it. This is the only line you'll find in it:
I suppose you have at least the basic knowledge of the structure of an XML file if you're interested in reading it using ASP .NET and C#.
So inside the XML file let's add these 3 movies:
Now open the main WebForm, WebForm1.aspx and drag a DataGrid on it from the Toolbox. As a result of adding the DataGrid the <asp:DataGrid> tag is created inside WebForm1.aspx:
We want the data inside the XML file to be displayed in the DataGrid. So open WebForm1.aspx.cs and we'll bind the DataGrid to the XML file.
We can see that the DataGrid DataGrid1 was created here:
So let's bind it. We'll do this in Page_Load.
For reading the XML file we need a DataSet which we created. The commented code is really easy to follow.
Now run the code and see the result.
The code creates a simple DataGrid holding the data from the XML file.
Of course, most of the time you'll want to select the columns which you want to appear in the DataGrid, for example you might not be interested to have a column with the year in which the movie was created, you want just the title and genre. This is easily accomplished, the same way you do it when working with databases. You set the AutoGenerateColumns attribute to False and use <asp:BoundColumn> tags to select which tags / columns you want to be displayed:
Further, if you want to make the DataGrid more esthetic, the tutorial 'Basics of using DataGrid' will show you how.
|Digg It! Del.icio.us Reddit StumbleIt Newsvine Furl BlinkList|
Rate this tutorial
There are no related tutorials.
Related Source Code
There is no related source code.
ASP.NET Job Search
From the creators of Geekpedia, a revolutionary new coupon website!
BargainEZ has coupons codes, printable coupons, bargains and it is the leading source of Passbook coupons for iPhone and iPod touch devices.