在我看来一切正常,但它会在运行时产生错误。当我删除这部分时 Text="" 出错了。所以我认为问题出在数据绑定(bind)上。所以我尝试了这样的替代方法 -6ren">
gpt4 book ai didi

c# - 无法将数据绑定(bind)到中继器内的标签

转载 作者:行者123 更新时间:2023-11-30 20:47:56 25 4
gpt4 key购买 nike

我的代码是这样的

<asp:Repeater ID="rptEvaluationInfo" runat="server">
<ItemTemplate>
<asp:Label runat="server" Id="lblCampCode" Text="<%#Eval("CampCode") %>"></asp:Label>

</ItemTemplate>

在我看来一切正常,但它会在运行时产生错误。当我删除这部分时

Text="<%#Eval("CampCode") %>" 

出错了。所以我认为问题出在数据绑定(bind)上。所以我尝试了这样的替代方法

    <asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<label><%#Eval("CampCode") %> </label>

</ItemTemplate>

而且它也很好用。谁能告诉我我的第一个代码有什么问题?

Note: I don't have access to the error message due to the special reasons on my project , that's why I have not posted it here. And I want to use ASP controls itself on the case that's why i haven't gone with my second solution

最佳答案

问题出在引号上。目前到处都有双引号,因此 ASP.NET 无法解析它。将外部的更改为单引号,如下所示:

Text='<%#Eval("CampCode") %>'

关于c# - 无法将数据绑定(bind)到中继器内的标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25310281/

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