Reputation: 12053
I want to display xml content at aspx page. There is my aspx code:
<asp:GridView ID="gvXML" runat="server" AutoGenerateColumns="True"
DataSourceID="xmlData">
</asp:GridView>
<asp:XmlDataSource runat="server" ID="xmlData"
DataFile="Items.xml">
</asp:XmlDataSource>
And there is XML content:
<?xml version="1.0" encoding="utf-8" ?>
<inventories>
<vehicle name="lanos" year="1984" instock="no">
<rate>ok</rate>
</vehicle>
<vehicle name="jeep" year="2013" instock="yes">
<rate>dziadowstwo</rate>
</vehicle>
</inventories>
What do I wrong, thanks for your suggestion.
Upvotes: 0
Views: 421
Reputation: 749
This should assist you. It appears you are missing the XPath. You can see further documentation here.
In short it might be as such.
<asp:XmlDataSource runat="server" ID="xmlData"
DataFile="Items.xml"
XPath="//vehicle">
</asp:XmlDataSource>
EDIT: although I know gridview is a nice pre-wired control you may also find it more beneficial to dig into a generic repeater and use item templates. in my web forms days it always seemed like there was something I needed to do that became overly messy with gv. However that is just an fyi for u down the road.
Upvotes: 2