sadier

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
asp.net中:datagrid 中的时间格式:
{0:D}; {0:DD-MM-YYYY} 
数字格式:{0:f2}

Format Pattern Name Example
d Short date format 8/27/1989
D Long date format Sunday, August 27, 1989
t Short time format 3:32 PM
T Long time format 3:32:00 PM
f Full date/time format
(short time) Sunday, August 27, 1989 3:32 PM
f Full date/time format
(long time) Sunday, August 27, 1989 3:32:00 PM
g General date/time format
(short time) 8/27/1989 3:32 PM
G General date/time format
(long time) 8/27/1989 3:32:00 PM
m or M Month day format August 27
r or R RFC 1123 format Sun, 27 Aug 1989 8:32:00 GMT
s Sortable date/time format 1989-08-27T15:32:00
u Universable sortable date/time format 1989-08-27 15:32:00z
U Universable sortable date/time format Sunday, August 27, 1989 11:32:00 PM
y or Y Year month format August, 1989

So, if we have a DataSource field that is a date/time field we can format the field as a just a date (without the time) using the following DataGrid declaration:



...

...




There are eight predefined numeric formatting specifies, summarized in the table below. For the Example column in the table below, the value used is 2003.0515, or 2003 for format providers that require integers.

Format Pattern Name Example
C or c Currency format $2,003.05
D or d Decimal format
(Works for integers only!) 2,003
E or e Scientific (exponential) format 2.003052e+003
F or f Fixed-point format 2003.05
G or g General format 2003.0515
N or n Number format 2,003.05
P or p Percent format 2,00305.15%
X or x Hexadecimal format
(Works with integers only!) 7D3

So, if we have a DataSource field that is, say, a price for our product, we can format the price as a currency using the following DataGrid declaration:
posted on 2004-07-21 19:58  毛小华  阅读(2306)  评论(0编辑  收藏  举报