开发者

Date formatting issue in GridView in asp.net

开发者 https://www.devze.com 2023-02-19 00:20 出处:网络
here is a Date column in GridView in my .net application. <asp:BoundField DataField=\"TestDate\" HeaderText=\"Date\" DataFormatString=\"{0:dd/MM/yyyy}\">

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.
0

精彩评论

暂无评论...
验证码 换一张
取 消