简体   繁体   中英

Date formatting issue in GridView in asp.net

here is a Date column in GridView in my .net application.

<asp:BoundField DataField="TestDate" HeaderText="Date" DataFormatString="{0:dd/MM/yyyy}">
</asp:BoundField>

date displaying properly on my pc in given format :

23/03/2011

but on test server it displaying in the following format:

3/23/2011 5:19:18 PM

which is incorrect.

Does anyone know how to resolve it?

Try this

 <asp:boundfield datafield="Your_Date_Column" dataformatstring="{0:MMMM d, yyyy}" htmlencode="false" />

Why htmlencode requires is

HTML-encoding field values helps to prevent cross-site scripting attacks and malicious content from being displayed. This property should be enabled whenever possible.

查看这篇讨论您所面临问题的文章。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM