DataFormatString="{0:格式字符串}"
在DataFormatString 中的 {0} 表示数据本身,而在冒号后面的格式字符串代表所们希望数据显示的格式;
数字、货币格式:
在指定的格式符号后可以指定小数所要显示的位数。例如原来的数据为「1.56」,若格式设定为 {0:N1},则输出为「1.5」。其常用的数值格式如下表所示:
格式字符串 输入 结果
"{0:C}" 12345.6789 ,345.68
"{0:C}" -12345.6789 (,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: 345.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--格式化字符串. DataFormatString="{0:格式字符串}" 在DataFormatString 中的{0} 表示数据本身,而在冒号后面的格式字符串 ... DataFormatString--格式化字符串[TrackBack] 2007-05-05 09:37 sliuqin. DataFormatString--格式化字符串 ...
DataFormatString--格式化字符串. DataFormatString="{0:格式字符串}" 在DataFormatString 中的{0} 表示数据本身,而在冒号后面的格式字符串代表所们希望数据显示的格式; 数字、货币格式: 在指定的格式符号后可以指定小数所要显示的位数。 ...
2005.5 以C2格式化之后¥2005.50128 以D格式化之后1282005.5 以E2格式化之后2.01E+0032005.5 以F4格式化之后2005.50002005.5 以G格式化之后2005.52005.5 以N3格式化之后2005.5000.25 以P格式化之后25.00%128 以X格式化之后802005.5 以00####.00格式化 ...
在Asp.net中有DataFormatString这样一个方法,是用来格式化字符用的,用DataFormatString="{0:#,###}">可以把数字变成会计表示法。 ... “# 数字占位符 如果格式化的值在格式字符串中出现“#”的位置有一个数字,则此数字被复制到输出字符串中。 ...
文件格式: 无法识别 - HTML 版
DataFormatString--格式化字符串. 程序:. public partial class FormatStrings : System.Web.UI.Page ... DataFormatString用于获取或设置指定列中各项的显示格式的字符串。 形式为{A:Bxx}。例如,格式化字符串{0:F2}将显示带两位小数的定点数。 ...
尝试通过使用DataView 控件中的< A1 > BoundField < / A1 > 类DataFormatString 属性格式化字符串。 这样做, 可能未正确格式化字符串。 当是基于Microsoft.NET 框架2.0 生成Web 应用程序可能会发生此行为。 不会注意此行为使用.NET 框架2.0 Beta 2 或早期 ...
DataFormatString="{0:格式字符串}" 在DataFormatString 中的 {0} 表示资料本身,而在冒号后面的格式字串、代表我们希望资.
当数据绑定控件处于编辑模式时,若要将格式化字符串应用到显示的值,应该同时将ApplyFormatInEditMode 属性设置为true。 复制ASPX代码保存代码<asp:BoundField DataField="HireDate" DataFormatString="{0:yyyy年M月d日}" HtmlEncode="false" ...

