Advertisement
Guest User

Untitled

a guest
Apr 24th, 2014
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. public class TestModel
  2. {
  3. [Display(Name = "Montant")]
  4. [DisplayFormat(DataFormatString = "{0:C2}")]
  5. public Decimal Amount
  6. {
  7. get;
  8. set;
  9. }
  10.  
  11. [Display(Name = "Date d'achat")]
  12. [DataType(DataType.Date)]
  13. public DateTime Date
  14. {
  15. get;
  16. set;
  17. }
  18. }
  19.  
  20. TestModel model = new TestModel
  21. {
  22. Amount = 1234.333M,
  23. Date = DateTime.Today.AddDays(-10)
  24. };
  25.  
  26. @Html.DisplayFor(x => x.Amout) => "1 234,33 €"
  27. @Html.ValueFor(x => x.Amount) => "1234,333"
  28.  
  29. @Html.DisplayFor(x => x.Date) => "23/03/2014"
  30. @Html.ValueFor(x => x.Date) => "23/03/2014 00:00:00"
  31.  
  32. @Html.ValueFor(x => x.Amount) = Convert.ToString(x.Amount, CultureInfo.CurrentCulture)
  33. @Html.ValueFor(x => x.Amount, "0.00") = String.Format(x.Amount, "0.00", CultureInfo.CurrentCulture)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement