【发布时间】:2015-04-08 10:45:12
【问题描述】:
class Report
{
[Display(Name = "Market Value")]
[DisplayFormat(DataFormatString = "£ {0:#,##0}", ConvertEmptyStringToNull = true)]
public int? MarketValue { get; set; }
}
当然它在视图中有效,结果是“£10,000”
@Html.DisplayFor(model => report.MarketValue)
如何通过服务器端这样的方式检索格式化的值?
string formattedValue = report.MarketValue.ToFormattedString();
提前致谢!
【问题讨论】:
-
我认为downvotes应该通过评论来完成。理想情况下,每个批评都应该是建设性的。
标签: c# model-view-controller data-annotations displayformat