DataGrid datalist data format setting expression

Source: Internet
Author: User
<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 ).

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.