我有一个动态绑定列(对于一个DetailsView)具有以下code:
I have a dynamic BoundField (for a DetailsView) with the following code:
BoundField bf1 = new BoundField();
bf1.DataField = "CreateDate";
bf1.DataFormatString = "{0:dd/MM/yyyy}";
bf1.HtmlEncode = false;
bf1.HeaderText = "Sample Header 2";
dv.Fields.Add(bf1);
但不知何故,它仍然显示了格式错误:2013-04-29T18:15:20.270
But somehow, it still shows the wrong format: 2013-04-29T18:15:20.270.
任何办法可以解决这个问题它显示29/04/2013呢?感谢您的帮助。
Any way I could fix this for it to show "29/04/2013" instead? Thanks for your help.
您可以添加 dataformatstring ={0:M-DD-YYYY}
属性绑定现场,像这样的:
You could add dataformatstring="{0:M-dd-yyyy}
" attribute to the bound field, like this:
<asp:BoundField DataField="Date" HeaderText="Date" DataFormatString="{0:dd-M-yyyy}" />
来源:着格式的日期时间使用dataformatstring
上一篇:ASP.NET编译器抱怨不匹配的框架版本,MiniProfiler编译器、框架、不匹配、版本
下一篇:是安全的使用ReaderWriterLockSlim在异步方法方法、安全、ReaderWriterLockSlim