我得到以下错误
Databinding methods such as Eval(),XPath(),and Bind() can only be used in the context of a databound control.
但我所要做的是在ASP.NET REPEATER控件内
<% if ( Eval("Message").ToString() == HttpContext.Current.Profile.UserName) %> <% { %> <asp:ImageButton runat="server" etc.... /> <% } %>
解决方法
语法是
<%# Eval("...") %>
你可以做一些事情
<asp:ImageButton Visible='<%# ShowImg(Eval(Container.DataItem,"Message")) %>' />
并在您的代码:
boolean ShowImg(string msg) { return (msg == HttpContext.Current.Profile.UserName); }