<Asp: boundcolumn datafield = "saleprice" headertext = "price" dataformatstring = "{0: N2}"> </ASP: boundcolumn> 2.00
-
Data format setting expression
-
. NET Framework format setting expression, which is applied to data before data is displayed in the column. This expression consists of optional static text and format specifiers in the following format:
{0:Format specifier}
Zero indicates the data element to be formatted in the column. Therefore, zero is usually used to indicate the first (and unique) element.Format specifierThere is a colon (:), which consists of one or more letters, indicating how to format the data. The format specifiers that can be used depend on the data type to be formatted: date, number, or other type. The following table shows an example of formatting expressions for different data types. For more information about formatting expressions, see formatting types.
| Format setting expression |
Apply to this data type |
Description |
| Price: {0: c} |
Numeric/decimal |
"Price:" is displayed, followed by a number in the currency format. The currency format depends on the region settings specified by the page command or the regional attribute in the web. config file. |
| {0: D4} |
INTEGER (cannot be used with decimal places .) |
An integer is displayed in the fields with four character widths filled with zero. |
| {0: N2} % |
Numeric |
The number accurate to the decimal point, followed by "% ". |
| {0: 000. 0} |
Numeric/decimal |
Number rounded to the decimal place. Less than three digits are filled with zero. |
| {0: d} |
Date/datetime |
Long Date Format ("Thursday, August 06,199 6 "). The date format depends on the regional settings of the page or web. config file. |
| {0: d} |
Date/datetime |
Short Date Format ("12/31/99 "). |
| {0: yy-mm-dd} |
Date/datetime |
The date in the format of year-month-day (96-08-06 ). |