ASP.Net数据绑定到带有文本的标签控件

时间:2018-04-04 20:44:40

标签: c# asp.net data-binding

如何使用绑定数据向标签添加文本?​​

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") %>'

1 个答案:

答案 0 :(得分:0)

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

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