Wel*_*ing 1 c# asp.net gridview
我的网格视图中有以下列
<asp:BoundField ItemStyle-Font-Bold="true"
DataFormatString="£{0:C2}" DataField="PriceBasePrice"
HeaderText="Price you pay" ItemStyle-Width="120" />
Run Code Online (Sandbox Code Playgroud)
传递给 Column 的值为 180.0
我认为:
DataFormatString="£{0:C2}"
Run Code Online (Sandbox Code Playgroud)
价值将返回为 £180.00
但它返回为 180.0 英镑
有谁知道我应该使用什么 DataFormatString ?
小智 5
您可能需要将 HtmlEncode 属性设置为 false,以防止首先将值转换为字符串。
\n\n或者,您可以只指定您自己的格式字符串:
\n\nDataFormatString="\xc2\xa3{0:###,###,###.00}"\nRun Code Online (Sandbox Code Playgroud)\n\n如果存在,则# 为空,直到被替换为值;如果存在,则将 0 替换为值,否则它们保持为 0。
\n\nSe 自定义数字格式字符串 - http://msdn.microsoft.com/en-us/library/0c899ak8.aspx
\n