[英]Convert decimal to currency in C# visual studio 2010
Hi guys i have a label on my website which shows the price of items on the pages. 大家好,我在我的网站上贴了标签,在页面上显示了物品的价格。 The t shirt page currently displays price for a t-shirt as 55 and i want it to show as £55 . T恤页面当前显示的T恤价格为55,我希望它显示为£55。 I would like the label to show price in £ currency format. 我希望标签以英镑货币格式显示价格。 My current code is below. 我当前的代码如下。 Can someone please point me in the right direction? 有人可以指出正确的方向吗? Thanks for your time... 谢谢你的时间...
<asp:Label ID="Label2" runat="server" Text='<%# Convert.ToDecimal(Eval("Price")).ToString("#,##0.00") %>'>
You just need to format it to currency for the specified culture. 您只需要将其格式化为用于指定区域性的货币。 The example below should work: 下面的示例应该工作:
<asp:Label ID="Label2" runat="server" Text='<%# Convert.ToDecimal(Eval("Price")).ToString("C", CultureInfo.GetCultureInfo("en-GB")) %>'>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.