【问题标题】:ASP.Net data binding to label control with textASP.Net 数据绑定到带有文本的标签控件
【发布时间】:2018-04-04 20:44:39
【问题描述】:

如何将文本添加到带有绑定数据的标签?

Text='<%# Bind("DeliveryPrice") %>'

尝试显示 £ 1.23。尝试了许多发布到论坛的示例,但没有成功:

Text='<%# "£: " +Eval("DeliveryPrice").ToString() %>'
Text='<%# String.Format("£: {0}", Bind("DeliveryPrice")) %>'
Text="£" + '<%# Bind("DeliveryPrice") %>'
Text="£" & '<%# Bind("DeliveryPrice") %>'
Text='£ <%# DataBinder.Bind(Container.DataItem,"DeliveryPrice") %>'
Text='<%# "£" & Bind("DeliveryPrice") %>'
Text='<%# "£" + Bind("DeliveryPrice") %>'

【问题讨论】:

    标签: c# asp.net data-binding


    【解决方案1】:

    Eval 函数有一个采用格式化字符串的重载:

    Text='<%# Eval("DeliveryPrice", "£: {0}") %>'
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-09-12
      • 1970-01-01
      • 2016-04-09
      • 1970-01-01
      • 2019-03-16
      • 2013-05-18
      相关资源
      最近更新 更多