Reputation: 4053
How to use conditional Eval inside Repeater control in this case:
if Actions.ShowDates(Eval("DatesAsPeriod").ToString(), Eval("DateList").ToString().Length) > 0
then show this:
<a href="Details.aspx?ActionID=<%# Eval("ID") %>"><%# Eval("Artist") %></a>
else show this:
<%# Eval("Artist") %>
Upvotes: 0
Views: 442
Reputation: 156938
You have to wrap if
statements in code tags:
<% if (Actions.ShowDates(Eval("DatesAsPeriod").ToString(), Eval("DateList").ToString().Length) > 0)
{
%>
<a href="Details.aspx?ActionID=<%# Eval("ID") %>"><%# Eval("Artist") %></a>
<%
}
else
{
%>
<%# Eval("Artist") %>
<%
}
%>
Inside a repeater, you should be able to use this:
<%# (Actions.ShowDates(Eval("DatesAsPeriod").ToString(), Eval("DateList").ToString()).Length > 0) ? "<a href="Details.aspx?ActionID='" + Eval("ID") + "'>" + Eval("Artist") + "</a>" : Eval("Artist") %>
Upvotes: 0
Reputation: 22054
You can wrap it into placeholders
<asp:PlaceHolder runat="server"
Visible='<%# Actions.ShowDates(Eval("DatesAsPeriod").ToString(), Eval("DateList").ToString().Length) > 0 %>'>
<a href="Details.aspx?ActionID=<%# Eval("ID") %>"><%# Eval("Artist") %></a>
</asp:PlaceHolder>
<asp:PlaceHolder runat="server"
Visible='<%# Actions.ShowDates(Eval("DatesAsPeriod").ToString(), Eval("DateList").ToString().Length) == 0 %>'>
<%# Eval("Artist") %>
</asp:PlaceHolder>
Upvotes: 1