I am creating a website for a bike shop where there should be two rows of bikes (image and text) side by side going down the page. I am trying to have the 2 rows in a gridview where the data is populated from an XMLfile. The problem I am having is that each row contains the same data as the one beside it. Does anyone know how I can fix this - ie. have new data in each row? I have never used gridview or an XML file so apologies if this is obvious!
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataSourceID="XmlDataSource1" AllowSorting="True" HorizontalAlign="Center"
Width="800px" AllowPaging="True" AllowCustomPaging="True" GridLines="None">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="ProductName"
runat="server"
Text='<%# XPath("ProductName") %>'></asp:Label>
<asp:Label ID="ProductDescription"
runat="server"
Text='<%# XPath("Description") %>'></asp:Label>
<asp:Label ID="Cost"
runat="server"
Text='<%# XPath("Cost") %>'></asp:Label>
<asp:Image ID="Image1"
runat="server" Height="200px"
ImageUrl='<%# XPath("Image") %>'
Width="200px" Align="left"/>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="ProductName"
runat="server"
Text='<%# XPath("ProductName") %>'></asp:Label>
<asp:Label ID="ProductDescription"
runat="server"
Text='<%# XPath("Description") %>'></asp:Label>
<asp:Label ID="Cost"
runat="server"
Text='<%# XPath("Cost") %>'></asp:Label>
<asp:Image ID="Image1"
runat="server" Height="200px"
ImageUrl='<%# XPath("Image") %>'
Width="200px" Align="left"/>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/Products.xml"
XPath="Products/Bikes/MaleBikes/RoadBikes"></asp:XmlDataSource>
Some of XML File:
<?xml version="1.0" encoding="utf-8" ?>
<Products>
<Bikes>
<MaleBikes>
< RoadBikes>
<ProductId>1</ProductId>
<ProductName>Ridley Fenix C20 1409AM Ultegra 11 Speed 2014</ProductName>
<Description>With the Fenix C20 you are now entering the top-end bikes in this range. Kitted out with Shimano Ultegra 11 speed components - giving 22 gears, Fulcrum Racing Quattro wheels, 4ZA Stratos parts, this bike is designed for faster, harder riding." </Description>
<Cost>€ 2950.00</Cost>
<Image>~/Images/MensBikes/2014 Ridley Fenix C20 Ultegra 11 Speed Carbon Road Bike.jpg</Image>
<CagegoryId>1</CagegoryId>
</RoadBikes>
<RoadBikes>
<ProductId>2</ProductId>
<ProductName>LOOK 675 Ultegra CT Road Bike 2013</ProductName>
<Description>
Look’s new all-rounder is as distinctive to ride as it is to look at, and it’s definitely more about power and precision than it is plushy pootling.
</Description>
<Cost>€ 3000</Cost>
<Image>~/Images/MensBikes/LOOK 675 Ultegra CT Road Bike 2013.jpg</Image>
<CagegoryId>1</CagegoryId>
</RoadBikes>
<RoadBikes>
<ProductId>3</ProductId>
<ProductName>Cube EPO (Electric) Bike 2012</ProductName>
<Description>Sporty pedelec with a difference! Design for purists who want to strike with "understatement". The tapered rigid fork and the lightweight, triple butted tubes make the frame stiff and fast. The disc brakes ensure the required braking performance for the higher average speed.</Description>
<Cost>€ 2880</Cost>
<Image>~/Images/MensBikes/Cube EPO (Electric) Bike 2012.jpg</Image>
<CategoryId>1</CategoryId>
</RoadBikes>