How to bind a XML file to a GridView using Asp.net C#

The following steps shows about bind a XML File to Gridview control in asp.net.

1.First Open Visual Studio 2010 > File > New > Website > Select Asp.net Empty Website > OK
2.Click on Solution Explorer > right click on solution > Add new Item > select XML file > Add
3.Write the following code in  XML file


4.Click on Solution Explorer > right click on solution > Add new Item > select WebPage > Add
 5.Now add a GridView control in your page.

6.Write the Following Code in code behind side

 
7.In the above code we are using ReadXml() method to the dataset.
8.ReadXml(): The ReadXml method provides a way to read either data only, or both data and schema into a DataSet from an XML document,
 
 DataSet Class.ReadXml();

9.Run Your Application then you will find your output like this...



0 comments:

Post a Comment