I need to display some average sums of currency values in my .net core asp mvc project.
I am using mvc 6 grid to display the data, and I have tried these solutions:
[DisplayFormat(DataFormatString = "{0:C}")]
public double? AverageCost { get; set; }
[DisplayFormat(DataFormatString = "{0:#.####}")]
public double? AverageCost { get; set; }
[RegularExpression(@"^\d+\.\d{0,2}$")]
public double? AverageCost { get; set; }
But still my values are displayed with several decimal places:
Am I missing something?
I know I can format the columns using the mvc 6 grid, but is there not a way of doing this in the ViewModel?
Note that this is NOT a duplicate of the suggested question.. If you actually read the questions you will see that.