我的代码是这样的
<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/