July 20, 2009

Populating Gridview with XML data

Let the needed xml file be “Test.xml”. It is placed in “App_Data” folder of the solution.
Test.xml


Now add a gridview “GridView1’ to the webform.
And in the code behind add the following code ..

protected void Page_Load(object sender, EventArgs e)
{
DataSet ds = new DataSet();
ds.ReadXml(Request.PhysicalApplicationPath + @"App_Data\Test.xml");
GridView1.DataSource = ds;
GridView1.DataBind();
}

No comments: