Just Dean
Mr Collins is my Dad

DataFormatting String {0:d}

December 17, 2007 01:11 by Dean

I've had this problem a few times so I thought I'd actually get round to blogging it.

Displaying Dates on a Datagrid is a nightmare when you don't want to display the full date and time in dd/mm/yyyy hh:mm:ss format.

There is a useful little property in the datagrid items editor which allows you to specify the format of the string using {0:d} formatting.

The problem I've found was that no matter what I did, it didn't make a bit of difference to the output.  The solution after much googling was was set one of the other properties..

The trick is to set HTMLEncode to False - as if by magic it works.

Actually it's not magic - the reason it works is that by default your data is html-encoded before the string formatting is applied - switching off html-encoding stops this happening and allows you to format it how you wish - this post explains in more detail:

http://tinyurl.com/hx8jb


Blogged with Flock


Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: Technical
Actions: E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

Related posts

Add comment


(Will show your Gravatar icon)  

  Country flag




Live preview

January 7. 2009 01:19

Gravatar