1

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?

1
  • Check out this post that discusses the problem you are facing. Commented Mar 23, 2011 at 12:38

1 Answer 1

4

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.
Sign up to request clarification or add additional context in comments.

1 Comment

yeah.but on my pc its displaying in the given format properly as i didn't add this attribute on my pc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.