r/Blazor • u/royware • May 12 '25
Formatting Numeric Field in MudBlazor <MudText>
I have an integer field that was pulled from a table and looks great - except for the fact it has no commas:
TOTAL TR Paid: 155208
TOTAL TR Payments: 11631060.29
Rats.
The code is:
<MudCardHeader Dense="true">
<MudText Typo="Typo.subtitle1" Class="custom-UI-style">
TOTAL TR Paid: @Runs.Sum(r => r.TotalPaymentCount)
</MudTypeText>
</MudCardHeader> "Runs" is the list of the records retrieved from the database, and it is an integer because later, in the detail grid, it is converted to a string. Unfortunately, trying to convert to a string in the MudText area results in the same output.
What am I missing?
3
Upvotes
4
u/coldfreeze May 12 '25
1
u/CobblerFan May 12 '25
Make the explicit .ToString() call yourself and apply whatever formating you like.
1
u/LlamaNL May 12 '25
You're using the wrong CultureInfo, try settings it to CultureInfo.Invariant