Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Contributor
3854 Points
691 Posts
Apr 30, 2012 03:50 PM|LINK
Hi,
I have the following model in MVC3:
public class ClientFormModel { ... [DisplayFormat(DataFormatString = "{0:n2}", ApplyFormatInEditMode = true)] public decimal? Salary { get; set; } ... }
As you can see I'm trying to display a decimal with 2 decimal places. However, my view is showing 4 decimal places. View looks as follows:
@Html.TextBoxFor(m => m.Salary, new { @class = "Textbox" })
Can someone explain how to use DataFormatString properly? Thanks.
vytautas.ziu...
Contributor
3854 Points
691 Posts
Using DataFormatString in the DisplayFormat attribute
Apr 30, 2012 03:50 PM|LINK
Hi,
I have the following model in MVC3:
public class ClientFormModel { ... [DisplayFormat(DataFormatString = "{0:n2}", ApplyFormatInEditMode = true)] public decimal? Salary { get; set; } ... }As you can see I'm trying to display a decimal with 2 decimal places. However, my view is showing 4 decimal places. View looks as follows:
@Html.TextBoxFor(m => m.Salary, new { @class = "Textbox" })Can someone explain how to use DataFormatString properly? Thanks.