Friday, July 23, 2010

DataFormatString for Gridview

Letter Code Format Example Result
C Currency with currency sign {0:C2} $3.14 Note rounding

E Exponential {0:E4} 3.1416E+000

F Fixed {0:F3} 3.142 Note rounding

G General {0:G3} 3.14
Same as currency but without symbol

P Percent {0:P0} %314
(Value must be 0.0314 to get %3.14)
dates and times

d (Lowercase d) Short date pattern {0:d} 1/13/2006

D (Uppercase D) Long date pattern {0:D} Friday, January 13, 2006

t (Lowercase t) Short time pattern {0:t} 2:23 PM

T (Uppercase T) Long time pattern and date {0:T} 2:23:45 PM

F (Uppercase F) Short time pattern and date {0:F} Friday, January 13, 2006 2:23:45 PM


m or M (Either case) Month and day pattern {0:m} January 13

y or Y (Either case) Year and month pattern {0:y} January 2006



To add text you as Literral String you must off HtmlEncode

HtmlEncode="false"
DataFormatString="My prefix {0:x} My suffix"

No comments:

Post a Comment