【发布时间】:2020-10-10 10:14:24
【问题描述】:
我想要在 CurrentCulture 的函数中为数字类型“int”的千分位和逗号。我正在尝试使用 DataFormtString 但它不起作用。 例如:1234567 ==> 123.456.789
我正在使用 MVC,我想在表格、输入等中格式化数字。
.Replace() 或类似的东西不是解决方案,我希望它具有以下功能 当前文化。
例如:
[DisplayName("Test")]
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:N}")] // Not working
public int? Example{ get; set; }
在视图中:
<span class="text">@Model.Example</span>
<input asp-for="Example" class="form-control form-control-sm" />
【问题讨论】:
-
its not working- 会发生什么? -
什么都没有,只显示完整的数字,没有点数
-
如果你不使用
@Html.DisplayFor(),显然它是行不通的。 -
当我尝试时。它得到
123.456.789,00。看来您的问题已经解决了? -
使用 DisplayFor 没问题,但无论如何使用 TagHelper ?
标签: asp.net-mvc asp.net-core integer dataformat displayformat