I am storing Amount in Decimal(18,2). But most of my data is actually integer with only few decimal. So when I display the amount for each item in the table, the number display is all 3.00, 4.00, 5.00 and so on.
I feel it is kind of weird to display all the 0 as the decimal point. I wish to format the number when display if the decimal point is 0.
Currently I am displaying the amount like this:
<td id="amnt@(item.FoodID)" class="amountfield">
@Html.DisplayFor(modelItem => item.FoodAmount)
</td>
Any idea?? Appreciate every help... thanks...
C programming language is a machine-independent programming language that is mainly used to create many types of applications and operating systems such as Windows, and other complicated programs such as the Oracle database, Git, Python interpreter, and games and is considered a programming foundation in the process of ...
What is C? C is a general-purpose programming language created by Dennis Ritchie at the Bell Laboratories in 1972. It is a very popular language, despite being old. C is strongly associated with UNIX, as it was developed to write the UNIX operating system.
Compared to other languages—like Java, PHP, or C#—C is a relatively simple language to learn for anyone just starting to learn computer programming because of its limited number of keywords.
In the real sense it has no meaning or full form. It was developed by Dennis Ritchie and Ken Thompson at AT&T bell Labbell LabNokia Bell Labs, originally named Bell Telephone Laboratories (1925–1984), then AT&T Bell Laboratories (1984–1996) and Bell Labs Innovations (1996–2007), is an American industrial research and scientific development company owned by multinational company Nokia.https://en.wikipedia.org › wiki › Bell_LabsBell Labs - Wikipedia. First, they used to call it as B language then later they made some improvement into it and renamed it as C and its superscript as C++ which was invented by Dr.
Looking at your code I assume that you are using ASP.Net MVC for your application. You can use DataAnnotation for formatting your data.
You can try using DisplayFormat in your model property.
[DisplayFormat(DataFormatString = "{0:0.##}")]
Decimal FoodAmount{ get; set; }
Use ToString(string)
with a custom format using the "#" custom format specifier
item.FoodAmount.ToString("0.##")
This shows up to two digits but omits them if they are non-significant zeroes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With