datarepeater 中的标签文本

发布于 2024-07-19 18:35:40 字数 557 浏览 6 评论 0原文

当我能够绑定数据并向我写入 html 页面时,我尝试在我的 datarepeater 中使用标签。

<asp:Label ID="lblID" runat="server"><%# DataBinder.Eval(Container.DataItem, "ID")%></asp:Label>

效果很好。

当我尝试获取文本值时,我得到“”。

标签 lblcurrentID = ri.FindControl("lblID") as Label;

结果: lblcurrentID.text = ""

这个相同的代码适用于我在 datarepeater 中的下拉列表。 我想知道这是否与标签转换为跨度标签有关。

<span id="template6_middlecontent1mAzoaNominationApproval0_dataReaper_ctl01_lblID">2009040100000888213</span>

I am trying to use a label in my datarepeater, when I am able to bind data and write to me html page.

<asp:Label ID="lblID" runat="server"><%# DataBinder.Eval(Container.DataItem, "ID")%></asp:Label>

which works fine.

When I try to get text value I get "".

Label lblcurrentID = ri.FindControl("lblID") as Label;

result:
lblcurrentID.text = ""

this same code works fine for the dropdownlist that I have in the datarepeater. I am wondering if this has anything to do with the label being converted to a span tag.

<span id="template6_middlecontent1mAzoaNominationApproval0_dataReaper_ctl01_lblID">2009040100000888213</span>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

天暗了我发光 2024-07-26 18:35:40

我以前遇到过这个问题,我不记得实际上找到了问题的解决方案,作为解决方法,我使用 来保存我的信息:

<asp:HiddenField runat="server" id="hiddenId" value='<%# Eval("Id") %>' />

顺便说一句,请注意用 ' 而不是 " 包装 Eval 语句,当您为服务器控件赋值时,.NET 会很挑剔。

I've ran into this issue before, I don't recall actually finding a solution to the problem, as a work around, I used an <asp:HiddenField> to hold onto the information for me:

<asp:HiddenField runat="server" id="hiddenId" value='<%# Eval("Id") %>' />

Note the ' instead of " wrapping the Eval statement btw, .NET is fussy when you're assigning values to server controls.

一桥轻雨一伞开 2024-07-26 18:35:40

您需要将 lblD.Text 与值绑定,而不是像

<%# DataBinder.Eval(Container.DataItem, "ID")%>

you need bind lblD.Text with the value not like

<%# DataBinder.Eval(Container.DataItem, "ID")%>

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文