Reputation: 271
I am working on a project that works with large numbers that I'm pulling in from SQL, reading to a list, and outputting to a grid using HTML Helper. Right now I'm trying to add commas to my numbers but I haven't been able to find any resources online that would explain a way to do that. Sorry, I'm kind of a beginner at this but I can answer questions if it helps to clarify. This is where I'm at:
<td>@Html.DisplayFor(modelItem => item.mbs.Original_Balance)</td>
<td>@Html.DisplayFor(modelItem => item.mbs.Collateral_Factor)</td>
<td>@Html.DisplayFor(modelItem => item.mbs.Current_Balance)</td>
Essentially, I'm asking how I would add commas to these so that the numbers display as "1,234,567"
Upvotes: 1
Views: 1034
Reputation: 67898
Add the DisplayFormat
attribute to the model, like this:
[DisplayFormat(DataFormatString = "N")]
public ... Original_Balance ..
Upvotes: 4
Reputation: 13960
Use ToString("0.00") or any of the many available format strings:
http://msdn.microsoft.com/en-us/library/dwhawy9k(v=vs.110).aspx
Upvotes: 1