DataFormatString 格式化字串

2022-03-26 15:14:39 字數 1155 閱讀 5475

還要設定htmlencode="false"

dataformatstring=""

在dataformatstring 中的 表示資料本身,而在冒號後面的格式字串代表所們希望資料顯示的格式;

數字、貨幣格式:

在指定的格式符號後可以指定小數所要顯示的位數。例如原來的資料為「1.56」,若格式設定為 ,則輸出為「1.5」。其常用的數值格式如下表所示:

格式字串 輸入 結果

"" 12345.6789 $12,345.68

"" -12345.6789 ($12,345.68)

"" 12345 12345

"" 12345 00012345

"" 12345.6789 1234568e+004

"" 12345.6789 1.2345678900e+004

"" 12345.6789 12345.68

"" 12345.6789 12346

"" 12345.6789 12345.6789

"" 123456789 1.234568e8

"" 12345.6789 12,345.68

"" 123456789 123,456,789.0000

"total: " 12345.6789 total: $12345.68

常用的日期時間格式:

格式 說明 輸出格式

d 精簡日期格式 mm/dd/yyyy

d 詳細日期格式 dddd, mmmm dd, yyyy

f 完整格式 (long date + short time) dddd, mmmm dd, yyyy hh:mm

f 完整日期時間格式

(long date + long time)

dddd, mmmm dd, yyyy hh:mm:ss

g 一般格式 (short date + short time) mm/dd/yyyy hh:mm

g 一般格式 (short date + long time) mm/dd/yyyy hh:mm:ss

m,m 月日格式 mmmm dd

s 適中日期時間格式 yyyy-mm-dd hh:mm:ss

t 精簡時間格式 hh:mm

t 詳細時間格式 hh:mm:ss

DataFormatString格式化字串的總結

最近真是在用vs2003,好多東西要重新整理一下,datagrid gridview有時不用模板列,那麼怎麼設定字元格式呢另外模板列格式請點 gridview在繫結顯示的各種格式 具體如下 dataformatstring 在gridview中如果直接設定dataformatstring為瀏覽會發現...

DataFormatString格式字串

dataformatstring格式字串 dataformatstring 在dataformatstring 中的 表示資料本身,而在冒號後面的格式字串代表所們希望資料顯示的格式 數字 貨幣格式 在指定的格式符號後可以指定小數所要顯示的位數。例如原來的資料為 1.56 若格式設定為 則輸出為 1....

DataFormatString格式字串

dataformatstring 在dataformatstring 中的 表示資料本身,而在冒號後面的格式字串代表所們希望資料顯示的格式 數字 貨幣格式 在指定的格式符號後可以指定小數所要顯示的位數。例如原來的資料為 1.56 若格式設定為 則輸出為 1.5 其常用的數值格式如下表所示 格式字串 ...