<asp:Repeater ID="rptEntries" runat="server" DataSourceID="dsEntries">
<ItemTemplate>
<%
if (Convert.ToInt16(Eval("entryWinner")) == 1)
{
%>
<%# "<div class=\"imgThumb draggable\" style=\"background-image:url('uploads/"
+ Eval("entryImagename") + "');\" data-id=\"" + Eval("pk_entryId")
+ "\"></div>"
%>
<%
}else{
%>
<%# "<div class=\"imgThumb draggable\" style=\"background-image:url('uploads/"
+ Eval("entryImagename") + "'); filter: grayscale(100%);\" data-id=\""
+ Eval("pk_entryId") + "\"></div>"
%>
<%
}
%>
</ItemTemplate>
</asp:Repeater>
我想在显示之前检查来自entryWinner的te值,但它会给出以下错误:
数据绑定方法,如Eval(),XPath()和Bind()只能是 在数据绑定控件的上下文中使用。
答案 0 :(得分:0)
您可以尝试这样的事情:
<asp:Repeater ID="rptEntries" runat="server" DataSourceID="dsEntries">
<ItemTemplate>
<%# String.Format("<div class=\"imgThumb draggable\" style=\"background-image:url('uploads/{0}');{1}\" data-id=\"{2}\"></div>"
,Eval("entryImagename")
,(Convert.ToInt16(Eval("entryWinner")) == 1)?"":" filter: grayscale(100%);",Eval("pk_entryId"))%>
</ItemTemplate>
</asp:Repeater>