Wednesday, September 24, 2008

DataFormatString Not Working in SharePoint

Today I was trying to use a BoundField to show some data on the main page of my SharePoint site. I bound the field to the DataSource and then went to edit the DataFormatString so that the data would be formatted into a currency format.


I would save the page and then refresh it and no currency formatting. I thought at first that I just didn't understand how the format string works so I went to MSDN and looked it up. As long as I put {0:c0} I should be able to get back a number with currency formatting with no decimal places. So I made sure that my page was saved and that it was rendering the most recent copy. It was!


So I did a quick search and came across this article from Rickey Whitworth that described a Bug in the DataFormatString. You need to make sure that the HtmlEncode property is set to false, otherwise the formatting will not take effect.


The minute I changed the HtmlEncode property to false, all of my currency formatting was there.

Labels:

1 Comments:

At February 19, 2009 at 5:40 PM , Blogger Unknown said...

Hey Michael, thanks for the link. I actually migrated by blog some time ago and didn't do a very good job of redirections. The updated URL to the DataFormatString post is http://www.whitworth.org/2005/11/14/bug-dataformatstring-for-gridview-column-not-working/

The new root for my blog is http://www.whitworth.org

 

Post a Comment

Subscribe to Post Comments [Atom]

<< Home