Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control

The syntax is

<%# Eval("...") %>

You could do something like

<asp:ImageButton Visible="<%# ShowImg(Eval(Container.DataItem,"Message")) %>" />

and in your codebehind:

boolean ShowImg(string msg)
{
     return (msg == HttpContext.Current.Profile.UserName);
}

Leave a Comment