With a set up like this:
<asp:ListView runat="server" ID="lvArticles">
<LayoutTemplate>
<div runat="server" id="itemPlaceholder" />
</LayoutTemplate>
<ItemTemplate>
<% if (Eval("Document") != null) { %>
<a href="/Documents/" + <%# Eval("Document.Id") %> + ".pdf">
<%# Eval("Document.Name") %>
</a>
<% } %>
</ItemTemplate>
</asp:ListView>
I get the following error:
Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.
Why is databinding methods like Eval() not allowed in if conditions like that? Is the ListView not a databound control?