在 ASP.NET 页面上的服务器端代码中使用 eval
<asp:Repeater ID="rptrParent" runat="server">
<ItemTemplate>
<li>
<a href="<% =ResolveUrl("~/cPanel/UserView.aspx?User=")%><%# Eval("StudentUserName") %>">
<span>
<% ProfileCommon pc = new ProfileCommon();
pc.GetProfile(Eval("StudentUserName").ToString());
Response.Write(pc.FirstName + "" + pc.LastName);
%>
</span>
</a>
</li>
</ItemTemplate>
以下错误
Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.
这部分出现
<% ProfileCommon pc = new ProfileCommon();
pc.GetProfile(Eval("StudentUserName").ToString());
Response.Write(pc.FirstName + "" + pc.LastName);
%>
<asp:Repeater ID="rptrParent" runat="server">
<ItemTemplate>
<li>
<a href="<% =ResolveUrl("~/cPanel/UserView.aspx?User=")%><%# Eval("StudentUserName") %>">
<span>
<% ProfileCommon pc = new ProfileCommon();
pc.GetProfile(Eval("StudentUserName").ToString());
Response.Write(pc.FirstName + "" + pc.LastName);
%>
</span>
</a>
</li>
</ItemTemplate>
The following error
Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.
is coming in this part
<% ProfileCommon pc = new ProfileCommon();
pc.GetProfile(Eval("StudentUserName").ToString());
Response.Write(pc.FirstName + "" + pc.LastName);
%>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在这种情况下,您需要像这样的完整调用:
In that context you need the full call like this:
好吧,伙计们,感谢您的帮助,但我得到了解决方案:
在代码隐藏文件中,我编写了以下函数:
Alright guys, thanks for the help, but i got the solution :
and in the code behind file, I wrote the following function :