Два варианта:
- DataFormatString
public class LocationModel
{
[Display(Name = "Latitude")]
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:G8}")]
public decimal Latitude { get; set; }
[Display(Name = "Longitude")]
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:G8}")]
public decimal Longitude { get; set; }
}
Математика
public class LocationModel
{
private decimal _latitude;
private decimal _longitude;
[Display(Name = "Latitude")]
public decimal Latitude
{
get
{
return Math.Round(_latitude, 8);
}
set
{
this._latitude = value;
}
}
[Display(Name = "Longitude")]
public decimal Longitude
{
get
{
return Math.Round(_longitude, 8);
}
set
{
this._longitude = value;
}
}
}