ASP.Net C#标签的日期格式字符串 [英] Date Formatstring for ASP.Net C# label
本文介绍了ASP.Net C#标签的日期格式字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用的标签在表单上显示美元(货币)值(不是FormView的一部分)。请协助将货币值显示为小数点后两位。
lblSumInsured.Text = dsApplication.ApplicationRegister [0] .SumInsured.ToString();
日期....
lblEndDate.Text = dsApplication.ApplicationRegister [0] .EndPeriod.ToString( MMMM d,yyyy);
解决方案
您只需要使用格式字符串 - 请参阅 http://msdn.microsoft.com/en-us/library/0c899ak8.aspx [ ^ ]例如。
货币
lblSumInsured.Text = string .Format( {0:C},dsApplication.ApplicationRegister [ 0 ]。SumInsured);
lblSumInsured.Text = decimal.Parse(dsApplication.ApplicationRegister [0] .SumInsured.ToString())。ToString(c ); 小>
I am using a label that displays dollar(currency) value on a form (Not part of a FormView). Please assist to display the currency value to two decimal places.
lblSumInsured.Text = dsApplication.ApplicationRegister[0].SumInsured.ToString();
for the date ....
lblEndDate.Text = dsApplication.ApplicationRegister[0].EndPeriod.ToString("MMMM d, yyyy");
解决方案
You just need to use format string - see http://msdn.microsoft.com/en-us/library/0c899ak8.aspx[^] for examples.
For currency
lblSumInsured.Text = string.Format("{0:C}", dsApplication.ApplicationRegister[0].SumInsured);
For Currency
lblSumInsured.Text = decimal.Parse(dsApplication.ApplicationRegister[0].SumInsured.ToString()).ToString("c");
这篇关于ASP.Net C#标签的日期格式字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文