Testing a Container.DataItem with inline code
I would do this. You bind your "visibility" function to the visible property of an asp:literal control:
<asp:Repeater id="myRepeater" runat="server">
<ItemTemplate>
<asp:literal runat='server' id='mycontrol'
visible='<%# DataBinder.Eval(Container.DataItem, "MyProperty").Equals("SomeValue") %>'>
<%# DataBinder.Eval(Container.DataItem, "MyProperty") %>
</asp:literal>
</ItemTemplate>
</asp:Repeater>
You could refactor it out to server side script.
<script runat="server">
protected string ShowIfEqual(RepeaterItem Item, string SomeValue) {
YourTypeThatIsDataBound _item = (YourTypeThatIsDataBound)Item.DataItem;
return _item.MyProperty == SomeValue ? _item.MyProperty : string.Empty;
}
</script>
And the call it inline as...
<%#ShowIfEqual(Container, "SomeValue")%>