Binding Xml Data into Gridview using C#

Hi, I have a XML file which contains a list of items/elements:

<Trail category="Zoo" ID="001">
		<Name>Cat Country</Name>
		<Description>Caracal, Jaguar, Leopard, Mountain Lion</Description>

	<Trail category="Zoo" ID="002">
		<Name>Wild Africa</Name>
		<Description>African Lion, Cheetah, Giraffe, White Rhinoceros, Zebra, African hunting dog, Banded Mongoose</Description>
<Trail category="Jurong Bird Park" ID="003">
		<Name>Flightless Birds</Name>
		<Description>Ostriches, Emus, Rheas, Cassowaries</Description>

	<Trail category="Jurong Bird Park" ID="004">
		<Name>World of Darkness</Name>
		<Description>Night Herons, Fish Owls, Snowy Owls</Description>

I can bind the data into a gridview. However, only the attributes are displayed(which is: category and ID). I need the elements to display out too (which is: Name,Description,Latitude and Longtitude).

Would anyone be kind enough to solve this problem for me?

And is it possible to populate a drop down list in using the same XML file? As in populating the category in the drop down list.

Thanks alot. :slight_smile:

Yes it is possible. We can help you if you give us the code you are using to bind

Thanks. I am now able to populate the XML data into the drop down list and has enable autopostback.

But no action taken place because I still can’t get the elements out from the xml file into the gridview.
I’m actually using XMLDataSource where the data file is kept at ~/App_Data/Trail.xml . The XPath Expression is /GIS/Trail. I’m not sure if this XPath Expression is correct. Please correct me if I’m wrong.

I need the XML data to be display like this in the gridview:


<td>Cat Country</td>
<td>Caracal, Jaguar, Leopard, Mountain Lion</td>

<td>Wild Africa</td>
<td>African Lion, Cheetah, Giraffe, White Rhinoceros, Zebra, African hunting dog, Banded Mongoose</td>

<td>Sea Lion Show</td>
<td>Burmese Python, California Sea Lione</td>

Can you help me with this problem?

Many thanks. :slight_smile: