Earth
Earth

Reputation: 3571

What is the string format to display the zeros (minimum 3 digits) after the decimal point in cshtml view page?

If the value is 3, then it should be display as 3.000, that is minimum to three decimals.

For eg., if the value is 2.05, then it is displaying as 2.05 as it is. But, it needs to be display as 2.050.

Code:

<span class="column-nos">@Html.Label("", String.Format("{0}", nos[i].Conversion.ToString()), new {@class = "numbers-conversion-value"})</span>

Upvotes: 0

Views: 1944

Answers (1)

von v.
von v.

Reputation: 17108

Format your values like this and do NOT convert the values into a string, drop the ToString()

String.Format("{0:0.000}", the_value)

your code should look like this:

<span class="column-nos">@Html.Label("", 
    String.Format("{0:0.000}", nos[i].Conversion),
    new {@class = "numbers-conversion-value"})
</span>

Upvotes: 1

Related Questions