I've a GridView in which i'm fetching the data from the XMLFile.
My XML file is shown below. In this XML file i've a Active node and i want to display only the data where the Active is 1 that's mean to fetch only first record but it's bringing all records.
here is the code to display in the GridView
XmlDataSource data = new XmlDataSource();
data.DataFile = Server.MapPath("~/XMLFiles/XMLFile1.xml");
GridView1.DataSource = data;
GridView1.DataBind();
Mahesh ChandPosted Feb 4, 2009, 8:42 AM
You can apply filter on XmlDataSource.
The XmlDataSource supports an XPath property you can use to filter the set of nodes exposed by the data source. In the example below, the XPath property is set to
Bookstore/genre[@name='Business']/book, to filter the nodes of the data source to show only those book elements under the "Business" genre. Be careful to specify correct syntax for the XPath property; otherwise, the data source may expose no nodes (and the asssociated data-bound control will not render).Read details here:
http://asp.dotnetheaven.com/aspnet/doc/ctrlref/data/xmldatasource.aspx