In my database I stored fields with the data type decimal
. I am using exactly the same (decimal
) data type in my ASP.NET application.
This is inside my view in order to display the value.
@Html.TextBoxFor(model => model.Stock, new { id = "Stock", @class = "k-textbox" })
This pretty straight forward. The only issue I am facing is that by default in my view the data is displayed with 4 decimal places.
I give you a few examples on how it looks and how it should look:
- 1,0000 => 1
- 1,2000 => 1,2
- 1,4300 => 1,43
- 1,8920 => 1,892
- 1,5426 => 1,5426
As you can see I want to cut off all the 0
as decimal places (only when displayed in the view).
Remember: I am using commas instead of decimal points.
Edit:
My model
public class Article
{
public decimal? Stock{ get; set; }
}