BoundField DataFormatString attribute not working
Date Published: 03 July 2006
I was stuck with a problem a few weeks ago where my DataFormatString on a BoundField in an 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.
Steve is an experienced software architect and trainer, focusing currently on ASP.NET Core and Domain-Driven Design.