gpt4 book ai didi

asp.net-mvc-3 - 如何在 mvc3 View 中进行数字格式化

转载 作者:行者123 更新时间:2023-12-04 04:46:05 25 4
gpt4 key购买 nike

我想得到输出 TotalAmount (例如: 1000000000 as 1,000,000,000 )但我的代码抛出了这个错误:

[ Templates can be used only with field access, property access, single-dimension array index, or single-parameter custom indexer expressions. ].



请在我的以下上下文中给我解决方案。
@Html.DisplayFor(modelItem => item.TotalAmount.ToString("#,##0.00"))

最佳答案

型号

[DisplayFormat(DataFormatString = "{0:0,0}")]
public virtual Decimal? TotalAmount{ get; set; }

查看
Html.EditorFor(model => model.TotalAmount)

关于asp.net-mvc-3 - 如何在 mvc3 View 中进行数字格式化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18170380/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com