I have a table in my view with columns of numerical data. In the footer of my table I have a row containing the totals of each column. The totals are adding up correctly, but I want the vales in them to be rounded to 2 decimal places, eg instead of 47.4386, I want it to display 47.44.
Sample code:
<table class="display" id="dailyreporttable">
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.DailyReportDate)
</td>
<td>
@Html.DisplayFor(modelItem => item.Estate)
</td>
<td>
@Html.DisplayFor(modelItem => item.BettingShop)
</td>
<td class="alignRight">
@Html.DisplayFor(modelItem => item.ShopBalance)
</td>
<td class="alignRight">
@Html.DisplayFor(modelItem => item.TotalCashIn)
</td>
}
<tfoot>
<tr>
<td>Total</td>
<td></td>
<td></td>
<td class="alignRight">@Model.Sum(item => item.ShopBalance)</td>
<td class="alignRight">@Model.Sum(item => item.TotalCashIn)</td>
</tr>
</tfoot>