Tim Mackey's Weblog
mostly.Net
|
|
Search
Categories
.Net Compact
.Net General
.Net Windows Forms
Asp.Net
Database
General
Mobile
Outdoors
Windows Server 2003
Archive
June, 2010 (2)
May, 2010 (1)
September, 2009 (1)
April, 2009 (1)
March, 2009 (1)
February, 2009 (2)
January, 2009 (1)
December, 2008 (2)
October, 2008 (2)
September, 2008 (1)
August, 2008 (1)
July, 2008 (1)
May, 2008 (2)
April, 2008 (2)
March, 2008 (2)
January, 2008 (4)
December, 2007 (1)
November, 2007 (4)
October, 2007 (3)
September, 2007 (3)
August, 2007 (3)
July, 2007 (5)
June, 2007 (1)
May, 2007 (5)
April, 2007 (4)
March, 2007 (3)
February, 2007 (4)
January, 2007 (3)
December, 2006 (1)
November, 2006 (1)
October, 2006 (3)
September, 2006 (3)
August, 2006 (6)
July, 2006 (2)
April, 2006 (2)
March, 2006 (2)
February, 2006 (4)
January, 2006 (9)
December, 2005 (10)
November, 2005 (3)
October, 2005 (1)
September, 2005 (4)
August, 2005 (6)
June, 2005 (2)
May, 2005 (3)
April, 2005 (3)
March, 2005 (5)
February, 2005 (2)
January, 2005 (3)
December, 2004 (3)
November, 2004 (5)
October, 2004 (3)
September, 2004 (3)
July, 2004 (5)
June, 2004 (3)
May, 2004 (2)
April, 2004 (3)
March, 2004 (7)
Blogroll
Sign In
Thursday, January 12, 2006
Fix: GridView DataFormatString not applied
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!
Comments [64]
| |
Tracked by:
http://vs/devblog/PermaLink,guid,8351df24-b7fc-4b3c-bc2b-5443c30e2cfd.aspx
[Pingback]
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!
marc
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.
John S.
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.
bobw
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!
manit
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.
snomag
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?
Frankie Baker
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.
Frankie Baker
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$
steve b
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.
Atakan E.
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.
Ramazan Kola
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
Remember Me
Comment (HTML not allowed)
Enter the code shown (prevents robots):
Live Comment Preview