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 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.
Category - Browse all categories
About Ardalis
Software Architect
Steve is an experienced software architect and trainer, focusing on code quality and Domain-Driven Design with .NET.