Tuesday, August 28, 2007

Formatting GridView Template Data using FormatString in ASP .NET

GridView DataFormatString samples to format the Grid View columns Data e.g. DataFormatString="{0:MM/dd/yy}" HeaderText="date2" HtmlEncode="False" SortExpression="date2">


{0:n}Numbers: Provides formatting with commas for a thousands separator.{0:e4} Numbers:Specifies scientific notation to 4 decimal places{0:ddd, MMM d yyyy}date1 Shows a date as Sat, Jan 14, 2006{0:MM/dd/yy}date2 Shows a date as 01/16/06
As you enter these formatting strings, you also need to change the HtmlEncode property to False for each field. Otherwise, the formatting won't show up properly. This changed from the beta versions of the various Visual Studio 2005 products; in those versions, you didn't have to set HtmlEncode property to false.

No comments:

 
Dotster Domain Registration Special Offer