gpt4 book ai didi

c# - 显示月份名称的 DataAnnotation

转载 作者:太空狗 更新时间:2023-10-30 00:40:32 24 4
gpt4 key购买 nike

如何在DataFormatString中显示完整的月份名称和年份?(2014年11月)

我尝试使用这个 DataAnnotation,但它没有给我想要的 o/p:

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

最佳答案

我不知道这有没有区别,但是怎么样;

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

来自 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.

关于c# - 显示月份名称的 DataAnnotation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27062800/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com