我们在asp.net中使用EVAL时如何格式化十进制值 [英] how to format the decimal values when we use EVAL in asp.net
本文介绍了我们在asp.net中使用EVAL时如何格式化十进制值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
如何格式化下面的一个
< asp:label id = productrate runat = server 文字 =' <% Eval(ProductRate)%>' / >
这里我的值为 80.0000。
但我希望结果为 80.00
谢谢
解决方案
< asp:label id =productraterunat =serverText ='< %String.Format({0:#。00},Eval(ProductRate))%>'/>
或者你可以从以下链接中获得帮助,
http://stackoverflow.com/questions/19332910/asp-net-c-sharp-decimal-formating-money [ ^ ]
http://stackoverflow.com/questions/1790852/format-decimal-value-in- gridview [ ^ ]
评估方法 [ ^ ]可以接受3个参数。其中一个是格式;)
请注意,您将获得的格式取决于当前的文化。请参阅: ASP.NET全球化和本地化 [ ^ ]。
Hi
how to format the below one
<asp:label id="productrate" runat="server" Text='<%Eval(ProductRate)%>' />
Here i am getting the values as 80.0000.
but i want the result as 80.00
Thanks
解决方案
Try to use this code.
<asp:label id="productrate" runat="server" Text='<%String.Format("{0:#.00}", Eval(ProductRate))%>' />
or you can help from the links below,
http://stackoverflow.com/questions/19332910/asp-net-c-sharp-decimal-formating-money[^]
http://stackoverflow.com/questions/1790852/format-decimal-value-in-gridview[^]
Eval method[^] can accept 3 parameters. One of them is format ;)
Note that format you'll get depends on current culture. See: ASP.NET Globalization and localization[^].
这篇关于我们在asp.net中使用EVAL时如何格式化十进制值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文