Asp.net
Eval()、XPath() 和 Bind() 等數據綁定方法只能在數據綁定控制項的上下文中使用
我收到以下錯誤
Eval()、XPath() 和 Bind() 等數據綁定方法只能在數據綁定控制項的上下文中使用。
但我想做的只是在 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); }