C# 格式化ASP.NET Gridview货币值

C# 格式化ASP.NET Gridview货币值,c#,asp.net,gridview,C#,Asp.net,Gridview,我的gridview中有以下列 <asp:BoundField ItemStyle-Font-Bold="true" DataFormatString="£{0:C2}" DataField="PriceBasePrice" HeaderText="Price you pay" ItemStyle-Width="120" /> 该值将返回为180.00英镑 但回报为180.0英镑 有人知道我应该使用什么DataFormatStrin

我的gridview中有以下列

<asp:BoundField ItemStyle-Font-Bold="true" 
            DataFormatString="£{0:C2}" DataField="PriceBasePrice"
            HeaderText="Price you pay" ItemStyle-Width="120" />
该值将返回为180.00英镑

但回报为180.0英镑


有人知道我应该使用什么DataFormatString吗?

如果删除2,默认情况下,它应该显示带有2个十进制值的数字

{0:C}

如果删除2,默认情况下,它应显示带有2个十进制值的数字

{0:C}

您可能需要将HtmlEncode属性设置为false,以防止首先将值转换为字符串

或者,您可以只指定自己的格式字符串:

DataFormatString="£{0:###,###,###.00}"
#在被替换为值(如果存在)之前为空,而0被替换为值(如果存在),否则它们保持为0


Se自定义数字格式字符串-

您可能需要将HtmlEncode属性设置为false,以防止首先将值转换为字符串

或者,您可以只指定自己的格式字符串:

DataFormatString="£{0:###,###,###.00}"
#在被替换为值(如果存在)之前为空,而0被替换为值(如果存在),否则它们保持为0

Se自定义数字格式字符串-