0

i have a database field with the type of Decimal(10,4) at my SQL server 2008, but on my asp.met mvc view the values will only be displayed with two decimal numbers ,, so let say the value in the database is 10.1234 the it will be displayed on the view as 10.12 only. So how i can define the field format to display all the decimal point as stored in the database

UPDATE:- First of all the entity framewrok create a model class for the table and set the object proprty as :-

public decimal Result { get; set; }

and on the view the result is displayed as follow:-

<div class="display-field">
        @Html.DisplayFor(modelitem => vlr.Result)
    </div>
    </td>
   <td>
    <div class="display-field">
        @Html.DisplayFor(modelitem => vlr.DateTaken)
    </div>

Even if the Result value in the database is something as 12.1234 ; it will be displayed on the view as 12.12 !!!!. BR

John John
  • 1
  • 72
  • 238
  • 501

1 Answers1

0

Add a DataAnnotation to the model:

[DisplayFormat(DataFormatString = "{0:#,###,##0.0000}", ApplyFormatInEditMode = true)]
public decimal Result { get; set; }
Jack
  • 1,453
  • 1
  • 15
  • 35