在Gridview中格式化为未绑定值的货币. [英] Format to currency an unbound value in a Gridview.

查看:84
本文介绍了在Gridview中格式化为未绑定值的货币.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只是想知道如何将Gridview中的未绑定值格式化为货币?
我要格式化的数字来自客户端脚本.

Just wondering how to format an unbound value in a Gridview to currency?
The numbers I want to format are derived from client side script.

推荐答案

请参阅MSDN文档中数字格式字符串的部分:http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx [
另外,请注意对区域性的依赖性,这可以由当前线程区域性定义或明确指定.请参阅:
http://msdn.microsoft.com/en-us/library/system.string. format.aspx [^ ],
http://msdn.microsoft.com/en-us/library/1ksz8yb7.aspx [ ^ ].

在上面提到的第二篇文章中,请注意使用实现接口IFormatProviderCultureInfo;有关用法,请参见代码示例.



由于货币格式始终取决于特定的文化,另请参见:
http://msdn.microsoft.com/en-us/library/ie/c6zyy3s9.aspx [^ ].

有关线程文化的信息,请参见:
http://msdn.microsoft.com/en-us/library/system. threading.thread.currentculture.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/system. threading.thread.currentuiculture.aspx [ ^ ].

-SA
Please see the part of MSDN documentation of numeric format string: http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx[^].

Locate the section "The Currency ("C") Format Specifier" and search by the keyword "currency" through all of this text for code samples, specification and related information.

Also, pay attention for dependency on the culture, which can be defined by a current thread culture or specified explicitly. Please see:
http://msdn.microsoft.com/en-us/library/system.string.format.aspx[^],
http://msdn.microsoft.com/en-us/library/1ksz8yb7.aspx[^].

In the second of the articles mentioned above, pay attention for using of CultureInfo which implements the interface IFormatProvider; for the usage, see the code samples.



As with currency formatting always depends on particular cultures, see also:
http://msdn.microsoft.com/en-us/library/ie/c6zyy3s9.aspx[^].

For thread culture, see:
http://msdn.microsoft.com/en-us/library/system.threading.thread.currentculture.aspx[^],
http://msdn.microsoft.com/en-us/library/system.threading.thread.currentuiculture.aspx[^].

—SA


我不确定"Gridview中的未绑定值"是什么意思,但是在UI端格式化字段的一种方法是使用 BoundField [ ^ ].例如
I''m not sure what did you mean by "unbound value in Gridview", but one option to format fields in UI side will be to use DataFormatString property of BoundField[^]. For example
<asp:BoundField HeaderText="Price/Unit"

                DataField="UnitPrice" SortExpression="UnitPrice"

                DataFormatString="{0:c}">


将GridView的UnitPrice字段格式化为Currency.有关不同DataFormatString的列表,请查看 [ ^ ] MSDN文章.


will format UnitPrice field of the GridView to Currency. For lists of different DataFormatString ,have a look at this[^] MSDN article.


这篇关于在Gridview中格式化为未绑定值的货币.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆