dataformatstring format of C # data binding

Source: Internet
Author: User

DataFormatString of data binding

Set the dataformatstring of BoundField, usually have the following several
Dataformatstring= "{0:c}" currency, the format of the currency depends on the culture setting in the current thread
Dataformatstring= "{0:e}" scientific notation
Dataformatstring= "{0:p}" percentage
Dataformatstring= "{0:f}" several decimal places
Dataformatstring= "{0:d}" m/d/yyyy as 10/30/2008
Dataformatstring= "{0:f}" Long date, short time. Dddd,mmmm dd,yyyy hh:mm aa such as, Monday, January30, 10:00am
Dataformatstring= "{0:d}" long date. Dddd,mmmm dd,yyyy such as: Monday,january 30,2008
Dataformatstring= "{0:f}" Long date, long time dddd,mmmm dd,yyyy HH:mm:ss AA
Dataformatstring= "{0:s}" ISO Standard time. Yyyy-mm-ddthh:mm:ss, such as: 2008-01-30t10:20:55am
Dataformatstring= "{0:m}" month and date MMMM DD, such as January30
Dataformatstring= "{0:g}" general format m/d/yyyy HH:mm:ss AA

format string input result
"{0:c}" 12345.6789 $12,345.68
"{0:c}"-12345.6789 ($12,345.68)
"{0:d}" 12345 12345
"{0:d8}" 12345 00012345
"{0:e}" 12345.6789 1234568E+004
"{0:e10}" 12345.6789 1.2345678900E+004
"{0:f}" 12345.6789 12345.68
"{0:f0}" 12345.6789 12346
"{0:g}" 12345.6789 12345.6789
"{0:g7}" 123456789 1.234568E8
"{0:n}" 12345.6789 12,345.68
"{0:n4}" 123456789 123,456,789.0000
' Total: {0:c} ' 12345.6789 total: $12345.68
Common Date-time formats:
Format Description Output format
D Thin Date format mm/dd/yyyy
D Detailed date format dddd, MMMM DD, yyyy
F Full Format (long date + short time) dddd, MMMM dd, yyyy hh:mm
Full Date Time format
(Long date + long time)
dddd, MMMM dd, yyyy HH:mm:ss
G General format (short date + short time) mm/dd/yyyy hh:mm
G General Format (short date + long time) mm/dd/yyyy HH:mm:ss
M,m month-day format MMMM DD
s medium Date time format Yyyy-mm-dd HH:MM:SS
T Lite time Format hh:mm
T Verbose time Format HH:mm:ss

<%# String.Format ("{0:yyyy-mm-dd}", Eval ("Effectivedate"))%>

<%# String.Format ("{0:yyyy-m-d}", DataBinder.Eval (Container.DataItem, "effectivedate"))%>

C # Data binding dataformatstring format

Related Article

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: 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.