Reputation: 41
I want to get the output TotalAmount
( for example: 1000000000
as 1,000,000,000
) but my code throws this error:
[ Templates can be used only with field access, property access, single-dimension array index, or single-parameter custom indexer expressions. ].
Please give me solutions on my below context.
@Html.DisplayFor(modelItem => item.TotalAmount.ToString("#,##0.00"))
Upvotes: 2
Views: 2409
Reputation: 843
You could try this one. ( it would handle even the nullable columns)
@Html.Raw(string.Format("{0:#,#.00}", Model.TotalAmount))
Upvotes: 0
Reputation: 10824
Model
[DisplayFormat(DataFormatString = "{0:0,0}")]
public virtual Decimal? TotalAmount{ get; set; }
View
Html.EditorFor(model => model.TotalAmount)
Upvotes: 3