BoundField DataFormatString attribute not working

I was stuck with a problem a few weeks ago where my DataFormatString on a BoundField in a GridView was not being applied. I had a chance to look at the code again today and found this very helpful post by Raj Kaimal with the fix this morning. The short answer is that you need to set HtmlEncode=“false” in order for the DataFormatString to work. The HtmlEncoding by default is designed to defeat cross site scripting attacks, but unfortunately the way it is implemented results in DataFormatString being ignored.