# Thursday, January 12, 2006
Thursday, January 12, 2006 4:01:38 PM (GMT Standard Time, UTC+00:00) ( Asp.Net )
for some bizarre reason, you have to set HtmlEncode=false on a bound column in a gridview, to get the DataFormatString to work.
i hope this helps somebody else staring at their gridview in disbelief as to why it doesn't work by default!

Tuesday, January 17, 2006 7:52:14 PM (GMT Standard Time, UTC+00:00)
THANK YOU! I have been trying this for 2 days!!!!!!!!!
Peter Rogers
Thursday, January 19, 2006 3:35:34 PM (GMT Standard Time, UTC+00:00)
Thanks!!!
Eric
Monday, January 23, 2006 3:41:25 PM (GMT Standard Time, UTC+00:00)
Excellent work. Couldn't figure this one out for the life of me!
Ryan
Friday, January 27, 2006 9:32:33 PM (GMT Standard Time, UTC+00:00)
DUDE! THANX!!!
Hank
Friday, February 17, 2006 6:13:43 PM (GMT Standard Time, UTC+00:00)
I was about to have a brain explosion when I decided to google this problem and found the solution here. Thank you! Why are Microsoft products so full of these glitches?! I must remember that Microsoft documentation is what they would like it to do, not what it does!
Al Reid
Monday, February 20, 2006 10:04:59 PM (GMT Standard Time, UTC+00:00)
Yes, this is crazy - your post saved me a lot of pain. Thanks!
Wednesday, February 22, 2006 3:15:12 PM (GMT Standard Time, UTC+00:00)
helped me too. Thanks.

Mitch
mitch
Friday, February 24, 2006 12:50:50 AM (GMT Standard Time, UTC+00:00)
i love you for this post.
Tuesday, March 07, 2006 1:21:38 PM (GMT Standard Time, UTC+00:00)
Thanks,Thanks,Thanks!!! from Italy too
bobo
Thursday, March 16, 2006 8:37:57 PM (GMT Standard Time, UTC+00:00)
I set the HtmlEncode=false for all the columns in my GridView, still doesn't work...
Alex
Tuesday, April 25, 2006 3:51:41 PM (GMT Daylight Time, UTC+01:00)
thank you (and google) very much.
Tuesday, May 02, 2006 5:02:21 AM (GMT Daylight Time, UTC+01:00)
Your post was my first Google hit when searching for this problem. I WOULD HAVE spent several hours fighting this if not for your post. THANK YOU THANK YOU THANK YOU!
Zack
Thursday, May 04, 2006 6:01:11 PM (GMT Daylight Time, UTC+01:00)
Many thanks! I blew nearly an hour trying to get a price field to format as currency... Then I google'd and found your post! (Thank You!)^3
atomicfroman
Monday, May 15, 2006 9:15:03 PM (GMT Daylight Time, UTC+01:00)
THANK YOU!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
TS
Monday, June 05, 2006 7:34:37 PM (GMT Daylight Time, UTC+01:00)
thanks!
Monday, June 26, 2006 7:09:35 PM (GMT Daylight Time, UTC+01:00)
Thanks a bunch!!!!
G
Wednesday, July 19, 2006 5:53:29 PM (GMT Daylight Time, UTC+01:00)
Thanks very much for this! Was starting to get on my nerves!
Richard
Wednesday, August 30, 2006 5:26:58 PM (GMT Daylight Time, UTC+01:00)
THANK YOU... I was going crazy!!
Roger
Wednesday, August 30, 2006 10:15:49 PM (GMT Daylight Time, UTC+01:00)
Awesome work. After 8 months this post is still getting hits.
THANKS FOR THE SOLUTION. I too, like many others, was going nuts..
T-Man
Wednesday, October 04, 2006 2:41:16 PM (GMT Daylight Time, UTC+01:00)
Thanks!!!
Petter
Friday, October 20, 2006 10:06:02 PM (GMT Daylight Time, UTC+01:00)
Thank you so much. Did anybody ever figure out if there is any logic behind this? Is it a bug?
Kent
Saturday, October 21, 2006 12:07:13 AM (GMT Daylight Time, UTC+01:00)
hi kent. no idea, seems like a bug to me!
tim
Wednesday, October 25, 2006 7:15:58 PM (GMT Daylight Time, UTC+01:00)
Tim,
Another butt saved here too - it was driving me batty. Thanks!
Ed
Monday, November 20, 2006 7:37:38 PM (GMT Standard Time, UTC+00:00)
Another bug bites the dust! Thx
Eric
Friday, December 08, 2006 10:10:45 AM (GMT Standard Time, UTC+00:00)
Great find - can't believe it doesn't work by default!!!
Max
Saturday, December 09, 2006 12:20:22 AM (GMT Standard Time, UTC+00:00)
Thanks for the great tip. I tried for an hour to figure out what was going on. I saw the HTMLEncode property and figured it had nothing to do with the DataFormatString property, go figure...

Mahalo!

Kevin
Kevin
Tuesday, December 19, 2006 12:13:35 PM (GMT Standard Time, UTC+00:00)
Thnnks
Mohammad Ajmal Yazdani
Friday, December 29, 2006 6:12:36 PM (GMT Standard Time, UTC+00:00)
Isn't this something?
Saif Khan
Monday, January 22, 2007 2:54:51 PM (GMT Standard Time, UTC+00:00)
Thank you!! Microsoft's quirks are endless.
Brian Bouta
Friday, January 26, 2007 7:42:35 PM (GMT Standard Time, UTC+00:00)
I've been trying to get that to work for 3 days and thought I was gonna kill some one thanks for the help.
Daniel
Thursday, February 08, 2007 8:09:57 PM (GMT Standard Time, UTC+00:00)
Over a year old and these two little lines of text are still helping people. Thank!!!
JDCook
Monday, February 12, 2007 3:10:44 PM (GMT Standard Time, UTC+00:00)
Thanks mate, these 2lines saved me tons of time.
Wednesday, February 21, 2007 1:59:18 AM (GMT Standard Time, UTC+00:00)
Did anyone Thank you for this?
Thank you !!!
Zaibar
Friday, March 09, 2007 4:36:10 PM (GMT Standard Time, UTC+00:00)
YOU ARE THE MAN, DOG
Jason
Monday, March 12, 2007 8:42:48 PM (GMT Standard Time, UTC+00:00)
Staring at the GridVeiw indeed.
Bloody MS, I just wasted 1.5 hours on this crap.
Thanks.
Paladin
Tuesday, March 13, 2007 6:22:46 PM (GMT Standard Time, UTC+00:00)
Thanks for the fix.

It doesn't work by default because it's MICROCRAP!
Alex
Wednesday, March 14, 2007 3:08:00 PM (GMT Standard Time, UTC+00:00)
THIS DID NOT WORK FOR ME. I have a column of smalldatetime and datetime and neither are affected by this. Here's my code:
----------------------------------------------------------
<asp:BoundField DataField="StudentBirthDate" DataFormatString="{0:MM/dd/yyyy}" HtmlEncode="false" SortExpression="StudentBirthDate" HeaderText="Student DOB" HeaderStyle-CssClass="TableHeaderStyle" HeaderStyle-HorizontalAlign="left" />
----------------------------------------------------------

I saw a post from Alex on Thursday, March 16, 2006 8:37:57 PM UTC. This fix didn't work for him either. Can someone address this for me please?
Wednesday, March 14, 2007 3:47:38 PM (GMT Standard Time, UTC+00:00)
hi frankie. your aspx code does work. there must be a problem with the way you are binding the data. can you post that code? cheers. tim.
tim
Wednesday, March 14, 2007 7:26:02 PM (GMT Standard Time, UTC+00:00)
Thanks for responding to me Tim. You said that my code should work and said their might be something wrong with the way i was binding. That made me think. I'm using a DataAdapter to call a stored procedure. In that stored procedure, i'm returning an XML column. To do this, I had to set the ReturnProviderSpecificTypes property to True before called the Fill method of the adapter. Once I took that property out of the mix, my columns sorted perfectly. Thanks for guiding my thinking.
Wednesday, March 14, 2007 7:36:54 PM (GMT Standard Time, UTC+00:00)
hi frankie. glad it helped. good luck.
tim
Friday, March 30, 2007 4:10:39 PM (GMT Daylight Time, UTC+01:00)
THANK YOU!
dave
Wednesday, April 18, 2007 9:16:25 AM (GMT Daylight Time, UTC+01:00)
Thank you!! :)
cr4zy
Wednesday, April 25, 2007 6:28:29 PM (GMT Daylight Time, UTC+01:00)
Thanks.
Nathan
Thursday, April 26, 2007 1:09:19 PM (GMT Daylight Time, UTC+01:00)
thanks a lot... its really helpful
Jeniifer
Tuesday, May 08, 2007 7:24:31 PM (GMT Daylight Time, UTC+01:00)
another thanks, ditto to all the exclamations of joy.
ian
Wednesday, May 09, 2007 6:23:57 PM (GMT Daylight Time, UTC+01:00)
Thanks man, it was helpful
PT
Wednesday, May 16, 2007 8:16:55 PM (GMT Daylight Time, UTC+01:00)
Thanks!
Pete Skaarup
Saturday, May 26, 2007 12:54:29 AM (GMT Daylight Time, UTC+01:00)
Thanks dude this was driving me crazy !!!
Burak
Wednesday, June 13, 2007 4:45:16 PM (GMT Daylight Time, UTC+01:00)
you are the man / woman... thanks! stupid microsoft.
Jon
Wednesday, June 20, 2007 12:10:48 AM (GMT Daylight Time, UTC+01:00)
Thanks for a time saver!
Ben
Thursday, June 21, 2007 3:05:54 AM (GMT Daylight Time, UTC+01:00)
Thanks that saved me from loading my gun.
Mark
Monday, July 02, 2007 4:54:44 PM (GMT Daylight Time, UTC+01:00)
Thanks!! it helped mee too . YOU ROCK
dev
Tuesday, July 03, 2007 3:12:33 PM (GMT Daylight Time, UTC+01:00)
Thanks!

I was getting quite frustrated.

ASP.NET rocks and so does M$
Thursday, July 26, 2007 2:28:57 PM (GMT Daylight Time, UTC+01:00)
Thanks to you and thanks to Google for helping me find you.
Jim G
Thursday, August 09, 2007 4:18:08 PM (GMT Daylight Time, UTC+01:00)
Thank you! Thank you! Thank you!
Dave S
Saturday, August 11, 2007 8:12:17 PM (GMT Daylight Time, UTC+01:00)
Want to add my thanks to the million or so others. Fortunately, thanks to you I didn't spend forever on this problem!

Chuck
Chuck
Thursday, August 30, 2007 9:13:09 PM (GMT Daylight Time, UTC+01:00)
Thanks for the tip, saved me some time!
Alan
Wednesday, September 19, 2007 1:37:07 PM (GMT Daylight Time, UTC+01:00)
Thank you man!
You saved the day.
Friday, September 21, 2007 3:42:09 PM (GMT Daylight Time, UTC+01:00)
Thanks from Portugal.
Rui
Thursday, November 08, 2007 9:56:03 PM (GMT Standard Time, UTC+00:00)
THANK YOU. I never would have guessed how to fix this.
Tom
Friday, January 04, 2008 2:20:20 PM (GMT Standard Time, UTC+00:00)
THANK YOU. God bless you.
Wednesday, February 13, 2008 2:29:11 PM (GMT Standard Time, UTC+00:00)
Thanks!Thanks!Thanks!Thanks!
Doug Wolfe
Thursday, November 20, 2008 5:33:08 PM (GMT Standard Time, UTC+00:00)
Thanks a million.
The wonders of Google and people who share!
Mike Toole
Sunday, February 14, 2010 8:40:02 AM (GMT Standard Time, UTC+00:00)
I have tried setting HtmlEncodeto false for some columns in my GridView with DataFormatString="{0:N3}"
But its still not working for me. Is there anything else I am missing?

Please help.
A.Salam
Name
E-mail
Home page

Comment (HTML not allowed)  

Enter the code shown (prevents robots):

Live Comment Preview