数据绑定方法(例如 Eval()、XPath() 和 Bind())只能在数据绑定控件的上下文中使用
我收到以下错误
Eval()、XPath() 和 Bind() 等数据绑定方法只能在数据绑定控件的上下文中使用。
但我想做的只是在 ASP.NET REPEATER 控件内
<% if ( Eval("Message").ToString() == HttpContext.Current.Profile.UserName) %>
<% { %>
<asp:ImageButton runat="server" etc.... />
<% } %>
I am getting the following error
Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.
but all I am trying to do is inside a ASP.NET REPEATER Control
<% if ( Eval("Message").ToString() == HttpContext.Current.Profile.UserName) %>
<% { %>
<asp:ImageButton runat="server" etc.... />
<% } %>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
语法是
执行类似and 的操作:
您可以在代码隐藏中
The syntax is
You could do something like
and in your codebehind:
另一种选择是:
这样就不需要后台代码了。
An alternative is this:
Then there is no need for code behind.
为时已晚,但我想以我的方式回答它,我用什么来实现它:
现在,如果消息等于用户名,则只会显示图像按钮。
这可能会对处于相同情况的其他人有所帮助。
在我的情况下,我需要检查 null 和空字符串...所以我实现如下:
谢谢
Its too late but i would like to answer it in my way, what i used to achieve it:
Now this will only show image button if Message is equal to username.
This might help any one else in same situation.
In my situation i needed to check null and empty string...so i implemented like this below:
Thanks
另一种实现方式:
Another way to implement it: