I rounded the loan amount value. But in my model I have defined the Loan Amount as Decimal. In Grid I need to show it as an Integer (need to avoid the last two zero's after the point).
For example: it shows as 22.00 if the data saved is 21.50. In the grid I need to display as 22 only - avoiding the zeros after the point.
Code:
@Html.DisplayFor(modelItem => item.LoanAmount)
You can use DisplayFormat attribute to make it work as per your choice.. Just decorate your property with displayformat and provide appropriate format.
You can create Helper method e.g.
DisplayDecimal
then in your .cshtml file you can call (referencing extension's namespace)
@Html.DisplayDecimal(modelItem => item.LoanAmount)
More information about rounding in C# is available at http://msdn.microsoft.com/en-us/library/3s2d3xkk.aspx
In your view you can simply add the following: