4

How to display the full month name and year in DataFormatString?(November-2014)

I tried using this DataAnnotation,but it does not give me the desired o/p:

 [DisplayFormat(DataFormatString="0:MMMM-yyyy")]
Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
Sumedha Vangury
  • 643
  • 2
  • 17
  • 43

2 Answers2

6

I don't know it makes a difference or not but how about;

[DisplayFormat(DataFormatString = "{0:MMMM-yyyy}")]

From DisplayFormatAttribute.DataFormatString property

The formatting string can be any literal string and usually includes a placeholder for the field's value. For example, in the formatting string "Item Value: {0}", the field's value is substituted for the {0} placeholder when the string is displayed in the DynamicField object. The remainder of the formatting string is displayed as literal text.

If the formatting string does not include a placeholder, the field's value from the data source is not included in the final display text.

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
2

You're missing brackets:

[DisplayFormat(DataFormatString="{0:MMMM-yyyy}")]
mellis481
  • 4,332
  • 12
  • 71
  • 118