2009-12-03 74 views
2

如何設置綁定返回的字符串格式?使用綁定格式化

<asp:Label ID="lbl" runat="server" Text='<%# Bind("Money") %>'> 
+1

您的意思是字符串在呈現的網頁上的外觀?或者你在談論string.Format? – 2009-12-03 11:24:23

+0

like: Bind(「Money」)。ToString(「C」); 但這個返回錯誤 – 2009-12-03 11:25:17

回答

6

很容易,它是這樣的:

<%= Bind ("price", "$ {0:f2}") %>

爲貨幣格式

+0

只是一個說明;過早地關閉卷曲而不是過早地變身 – panhandel 2014-09-05 20:55:00

0

用的String.format:

Text='<%# String.Format("{0:f2}", (double)Bind("Money")) %>' 
+0

也就是說,如果Money是雙倍... – CRice 2009-12-03 11:44:20

0

Text='<%# Bind("Money","{0:f2}") %>'

0123取代