The .NET Framework format sets an expression, which is applied to the data before the data is displayed in the column. This expression consists of optional static text and format specifiers represented by the following format:
{0: Format Specifier}
Zero-Parameter index, it indicates data elements to format in columns; therefore, usually use zero to indicate the first (and unique) elements. There is a colon (:) in front of Format Specifier, which consists of one or more letters indicating how to format the data. The format specifier that can be used depends on the data type to format: Date, numbers, or other types. The following table shows an example of setting an expression in the format of different data types. For more information on formatting, see
Format type
.
Format Setting Expression Apply to this data Type Description Price: {0: C} Numeric / Decimal Displays "Price:", followed by the number represented by currency format. The currency format depends on the regional settings specified by the regional attributes in the page directive or web.config file. {0: D4} INTEGER (cannot be used with a decimal.) Display integers in the four character wide fields that are filled. {0: N2}% NUMERIC Shows the number of two digits after the decimal point, followed by "%". {0: 000.0} Numeric / Decimal is round to a number of numbers after the decimal point. No three digits are filled with zero. {0: D} DATE / dateTime Long Date Format ("Thursday, August 06, 1996"). The date format depends on the area setting of the page or the web.config file. {0: D} DATE / dateTime Short date format ("12/31/99"). {0: YY-mm-dd} Date / DateTime Date (96-08-06) in the year - month - day of the year (96-08-06).