Repeater and XmlDataSource

J

Jon Davis

My repeater is not repeating any items.

I am trying to use an XmlDataSource to load a custom .sitemap file having
content similar to as follows:

<siteMap>
<siteMapNode title="Home" description="Home" url="~/default.aspx">
<siteMapNode title="Buy" description="Buy stuff"
url="~/Buy.aspx" />
<siteMapNode title="Sell" description="Sell stuff"
url="~/sell.aspx" />
</siteMapNode>
</siteMap>

I've put this file, called "Nav.sitemap", into the path
"~/App_Files/navXML/Nav.config".

In my TopNav.ascx file, I have a repeater as such:


<div>
<ul><asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate><li><a href='<%# XPath("@url") %>'><%# XPath("@title")
%></a></li></ItemTemplate>
</asp:Repeater>
</ul>
</div>

In the code-behind, I have something similar to the following:

protected void Page_Load(object sender, EventArgs e)
{
XmlDataSource xmlSource = new XmlDataSource();
xmlSource.DataFile = MapPath("~/App_Files/navXML/Nav.sitemap");
xmlSource.XPath = "/siteMap/siteMapNode/siteMapNode";
xmlSource.DataBind();
Repeater1.DataSource = xmlSource;
Repeater1.DataBind();
}

When I run this as posted on the machine I'm posting this newsgroup post (at
home), it works fine, but for some reason on the actual development server
at the office the output is blank. If I add a <HeaderTemplate />, the
repeater shows itself to be functional, but simply no items are displayed.
There is no error messages, the <ItemTemplate /> simply never renders any
items. I've validated that the XPath string is identical to what's described
above. What could be some of the causes of this behavior? Any ideas??

Thanks,
Jon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top