Why doesn't the DataFormatString format the data in my grid column?

Here's one that has bitten me a couple times.  When working with the GridView control in .Net 2.0, and you apply a format string to a column, such as:

<asp:BoundField DataField="Amount" HeaderText="Paid Amount" DataFormatString="{0:c}" />

the column doesn't show any formatting.  This should render the column as a currency value ($x.xx), but it doesn't.  By adding HtmlEncode='False' to your BoundField object, it will then work.

<asp:BoundField DataField="Amount" HeaderText="Paid Amount" HtmlEncode="false" DataFormatString="{0:c}" />

Why?  Here's a good post that has been around a while on the topic.

Perhaps I'll remember this now instead of wasting a few minutes finding the solution again and again...lol.

permalink Permalink or Trackback Comment Comments (0) Cat ASP.Net
Technorati: No reaction yet!
Tags: , ,
Actions: E-mail

Was this helpful?

If you liked this or found it helpful, please digg it, stumble it, buzz it, whatever it, to say thank you.





Add to Technorati Favorites

 
 If you would like to receive these posts as they happen, you can subscribe to my feed or receive my posts in your email.

Related Posts

Add comment



(Will show your Gravatar icon)  

biuquote
  • Comment
  • Preview
Loading



Check it out mango: Any links must be entered as http://www.somewhere.com with nothing touching it. Anything else will be mangled. This is to help combat spam and to also ensure the masses know of this little tidbit before they click Save comment below. :) I have this down to remind me to do something with it, but I take things slow and easy on the old horse.

Keeps her regular don't ya know, and I wouldn't want to disturb that.



CSS Template by RamblingSoul | Illinois Wine. Adapted to BlogEngine by Wayne John
EatonWeb Blog Directory  Blog Directory Blogger Forum: About Blogging for Bloggers DaniWeb - IT Professionals' Lounge Community