在网格中显示货币符号

发布于 2024-11-08 23:38:51 字数 135 浏览 5 评论 0原文

我正在从表中的共享点库检索数据。对于货币栏,我将其设置为印度货币。我将 spfield.dataformatstring 设置为 {0:c}。默认情况下显示 $ 符号而不是印度货币符号。

如何显示实际的货币符号?

提前致谢。

I am retrieving data from sharepoint library in a table. For currency column, i set it as indian currency. And i set spfield.dataformatstring as {0:c}. It is by default showing $ symbol instead of indian currency symbol.

How can i show the actual currency symbol?

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

画离情绘悲伤 2024-11-15 23:38:51

您需要将正确的区域性信息传递给格式化程序,但是我不确定您是否可以直接在复合格式中执行此操作,但是您可以执行以下操作:

string.Format("The total amount is: {0}", total.ToString("c2",
                                          CultureInfo.CreateSpecificCulture("in-IN"));

另一个选项是确保您已正确设置整个页面或站点的文化 - 显然服务器认为它是服务页面在 en-US 文化中默认为 up。

这通常可以在 web.config 中使用 元素在站点范围内完成,或者在页面中的页面级别完成指令 <%@ Page UICulture="in" Culture="in-IN" %>

话虽如此,SharePoint 增加了一些额外的复杂性,要​​求网站使用所需的语言创建,因此需要在其上安装正确的语言包。

You need to pass in the correct culture information to the formatter, however I'm unsure if you can do that directly within the composite formatting, however you could do something like:

string.Format("The total amount is: {0}", total.ToString("c2",
                                          CultureInfo.CreateSpecificCulture("in-IN"));

The other option is to ensure that you've set the culture of your page or site as a whole correctly - clearly the server thinks it's serving pages up by default in the en-US culture.

This can usually be done site wide in the web.config, using the <globalization uiCulture="in" culture="in-IN" /> element, or at the page level in the page directive <%@ Page UICulture="in" Culture="in-IN" %>.

That being said, SharePoint adds some additional complexity into the mix, requiring the site to have been created with the required language, and therefore to have the right language packs installed on top of it.

马蹄踏│碎落叶 2024-11-15 23:38:51

您需要设置正确的文化。

You need to set the correct culture.

乖乖哒 2024-11-15 23:38:51

我得到了解决方案。这是代码片段:

XmlReader reader = XmlReader.Create(new StringReader(spfield.SchemaXml));
XmlDocument doc = new XmlDocument();
XmlNode node = doc.ReadNode(reader);
string curSymbol = "";
if (node.Attributes["LCID"] != null)
{
    string lcidValue = node.Attributes["LCID"].Value;
    CultureInfo ci = new CultureInfo( Convert.ToInt32(lcidValue));
    curSymbol = ci.NumberFormat.CurrencySymbol;                
}
field.HtmlEncode = false;
field.DataFormatString = curSymbol + " {0:#,###.##}";

无需在 web.config 中执行任何操作即可正常工作。

I got the solution. Here is the code snippet:

XmlReader reader = XmlReader.Create(new StringReader(spfield.SchemaXml));
XmlDocument doc = new XmlDocument();
XmlNode node = doc.ReadNode(reader);
string curSymbol = "";
if (node.Attributes["LCID"] != null)
{
    string lcidValue = node.Attributes["LCID"].Value;
    CultureInfo ci = new CultureInfo( Convert.ToInt32(lcidValue));
    curSymbol = ci.NumberFormat.CurrencySymbol;                
}
field.HtmlEncode = false;
field.DataFormatString = curSymbol + " {0:#,###.##}";

It is working fine without do anything in web.config.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文