简体   繁体   中英

ASP.Net data binding to label control with text

How to add text to label with bound data?

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

Trying to display £ 1.23. Tried numerous examples posted to forums and no luck:

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM