Displaying XML data in DataGrid in ASP.NET

Posted by Susanthampy under ASP.NET category on | Points: 40 | Views : 2243
1)The .net framework provides the Dataset object which can handle data from variety of sources like SQL, XML etc.

2)The DataSet has a ReadXML() method which is used to read data from an XML file.

Code for binding XML data in DataGrid:


using System;
using System.Data;

public partial class _Default : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
string strXMLFile = MapPath("products.xml");
lblXMLFileName.Text = strXMLFile;

DataSet objDataSet = new DataSet();

dgServers.DataSource = objDataSet.Tables[0].DefaultView;


Xml file products.xml,



This is a simple example .

Comments or Responses

Posted by: T.saravanan on: 4/28/2011 Level:Silver | Status: [Member] [MVP] | Points: 10
Kindly post your code inside the code tag its looking good.
Posted by: Susanthampy on: 4/29/2011 Level:Bronze | Status: [Member] [MVP] | Points: 10
nxt time..........definitely
Posted by: Susanthampy on: 5/4/2011 Level:Bronze | Status: [Member] [MVP] | Points: 10

Login to post response