I am trying to add a conditional statement to my repeater, but I am receiving the following error:
- Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.
The code I am trying to use is as follows:
<asp:Repeater ID="repLeftmenu" DataSourceID="xmlMenu" runat="server" EnableViewState="false">
<HeaderTemplate>
<ul class="leftMenu">
</HeaderTemplate>
<ItemTemplate>
<li>
<% If XPath("@url").ToString = HttpContext.Current.Request.Url.AbsolutePath.ToString Then%>
<a href="<%# XPath("@url") %>">
<%# XPath("@title")%>
</a>
<% Else %>
<a href="<%# XPath("@url") %>">
<%# XPath("@title")%>
</a>
<% End If%>
</li>
</ItemTemplate>
<FooterTemplate>
</ul>
</FooterTemplate>
</asp:Repeater>
Is there something wrong with my syntax?
Thanks, crjunk
If Then ... Elseand the code in theElse ... End If. Are you sure you need the if/else construct? - Michiel van Oosterhout