gpt4 book ai didi

asp.net - 数据绑定(bind)方法(例如 Eval()、XPath() 和 Bind())只能在数据绑定(bind)控件的上下文中使用

转载 作者:行者123 更新时间:2023-12-02 05:28:53 25 4
gpt4 key购买 nike

我收到以下错误

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);
}

关于asp.net - 数据绑定(bind)方法(例如 Eval()、XPath() 和 Bind())只能在数据绑定(bind)控件的上下文中使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2571545/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com