ASP.NET repeater only renders the first item in my XML data source

Matthew Layton

I have an XML Data Source:

<?xml version="1.0" encoding="utf-8" ?>
<Data>
    <items>
        <item id="1" text="X" />
        <item id="2" text="Y" />
        <item id="3" text="Z" />
    </items>
</Data>

In my page I have wired this up to an asp:XmlDataSource:

<asp:XmlDataSource runat="server" ID="data" DataFile="~/items.xml" />

And bound this to an asp:Repeater:

<asp:Repeater runat="server" ID="list" DataSourceID="data">
    <HeaderTemplate>
        <ul>
    </HeaderTemplate>
    <ItemTemplate>
        <li data-id="<%# XPath("item/@id") %>"><%# XPath("item/@text") %></li>
    </ItemTemplate>
    <FooterTemplate>
        </ul>
    </FooterTemplate>
</asp:Repeater>

But I am only getting the first item in the items list. How do I get them all?

Mike Atkisson

First add an `XPath="/Data/items/item"' attribute to your XmlDataSource, then change the li elements in the ItemTemplate to:

<li data-id="<%# XPath("@id") %>"><%# XPath("@text") %></li>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

ASP.NET WebForms Nested Repeater With LINQ Group Data Source

From Dev

repeater item command in asp.net

From Dev

ASP.NET Converting repeater item to the textbox

From Dev

Hiding the first item of an ASP.NET Repeater causes error: not a valid identifier

From Dev

Is there an ASP.NET databindable control (like Repeater), which only expects a single item?

From Dev

Is there an ASP.NET databindable control (like Repeater), which only expects a single item?

From Dev

jQuery is not finding Asp.net repeater alternating item

From Dev

ASP.NET Repeater Item add divider after each row

From Dev

ASP Repeater not showing data

From Dev

My loop is only checking the first array item

From Dev

My loop is only checking the first array item

From Dev

Loading data from repeater in asp.net in content slider?

From Dev

fetching data in repeater's ItemCommand event in asp.net?

From Dev

ASP.NET: Table with Repeater control and alternating data in same for

From Dev

button click event in repeater control to show data in same repeater in asp.net c#

From Dev

The 'data source' keyword is not supported. (ASP.Net app, Entity-framework 5, Code first, migrations)

From Dev

NavigateUrl on Repeater ASP.net

From Dev

NavigateUrl on Repeater ASP.net

From Dev

ACF Add Class if first item in repeater array

From Dev

How to change image source inside LinkButton in Repeater Asp.Net C#

From Dev

ASP.NET Downloading exported excel sheet sometimes renders the source page itselft

From Dev

Delete an item from an asp:Repeater using jQuery

From Dev

MultipleHiddenInput renders only if with initial data

From Dev

asp.net Repeater Button does not fire event on first page load but after postback it does

From Dev

Changing the last datarow from a asp:repeater table if data is shown in asp:label using vb.net

From Dev

Data Source Menu In ASP.NET 2010

From Dev

C# ASP.Net - Issue when trying to bind labels within a Repeater, in my .cs code

From Dev

Why is my recyclerview only displaying the content of the first item?

From Dev

.data() gets the first list item's data attribute only?

Related Related

  1. 1

    ASP.NET WebForms Nested Repeater With LINQ Group Data Source

  2. 2

    repeater item command in asp.net

  3. 3

    ASP.NET Converting repeater item to the textbox

  4. 4

    Hiding the first item of an ASP.NET Repeater causes error: not a valid identifier

  5. 5

    Is there an ASP.NET databindable control (like Repeater), which only expects a single item?

  6. 6

    Is there an ASP.NET databindable control (like Repeater), which only expects a single item?

  7. 7

    jQuery is not finding Asp.net repeater alternating item

  8. 8

    ASP.NET Repeater Item add divider after each row

  9. 9

    ASP Repeater not showing data

  10. 10

    My loop is only checking the first array item

  11. 11

    My loop is only checking the first array item

  12. 12

    Loading data from repeater in asp.net in content slider?

  13. 13

    fetching data in repeater's ItemCommand event in asp.net?

  14. 14

    ASP.NET: Table with Repeater control and alternating data in same for

  15. 15

    button click event in repeater control to show data in same repeater in asp.net c#

  16. 16

    The 'data source' keyword is not supported. (ASP.Net app, Entity-framework 5, Code first, migrations)

  17. 17

    NavigateUrl on Repeater ASP.net

  18. 18

    NavigateUrl on Repeater ASP.net

  19. 19

    ACF Add Class if first item in repeater array

  20. 20

    How to change image source inside LinkButton in Repeater Asp.Net C#

  21. 21

    ASP.NET Downloading exported excel sheet sometimes renders the source page itselft

  22. 22

    Delete an item from an asp:Repeater using jQuery

  23. 23

    MultipleHiddenInput renders only if with initial data

  24. 24

    asp.net Repeater Button does not fire event on first page load but after postback it does

  25. 25

    Changing the last datarow from a asp:repeater table if data is shown in asp:label using vb.net

  26. 26

    Data Source Menu In ASP.NET 2010

  27. 27

    C# ASP.Net - Issue when trying to bind labels within a Repeater, in my .cs code

  28. 28

    Why is my recyclerview only displaying the content of the first item?

  29. 29

    .data() gets the first list item's data attribute only?

HotTag

Archive