【发布时间】:2013-07-21 14:18:10
【问题描述】:
如何在 Eval() 方法中为丹麦语价格和右侧的货币符号格式化价格 i C#?
我的 .aspx 页面中有以下内容来显示价格:
<td class="text-right price-col"><%# Eval("Price", "{0:c}") %></td>
但这会将价格显示为例如韩币。 79,00 ..我想要的是79,00 kr.
我看到这篇帖子Changing Currency Symbol location in System.Globalization.NumberFormatInfo 并在代码隐藏中添加了这个方法,这给了我想要的结果:
<td class="text-right price-col"><%# PriceFormat(79) %></td>
protected string PriceFormat(decimal price) {
System.Globalization.CultureInfo danish = new System.Globalization.CultureInfo("da-DK");
danish = (System.Globalization.CultureInfo)danish.Clone();
// Adjust these to suit
danish.NumberFormat.CurrencyPositivePattern = 3;
danish.NumberFormat.CurrencyNegativePattern = 3;
decimal value = price;
string output = value.ToString("C", danish);
return output;
}
但是我可以使用 PriceFormat 方法和 Eval() 方法来获得正确的价格作为参数,或者修改 Eval() 方法中的格式来做同样的事情吗? 在示例中,我只是插入了一个静态值作为参数 (79)。
【问题讨论】:
标签: c# localization currency