惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - xixi8820

输入框验证输入数字的js 关于VS2005中GridView的自定义分页,单选、多选、排序、自增列的简单应用(转载的) 使用t-sql从身份证号中提取生日(转自别人,个人学习收藏用) 一个最简单的登录例子 js中setTimeout与setInterval的区别 js将html中的内容导出word、或者excel文件的方法 javascript 获得指定日期的临近日期的方法 asp.net 2.0 生成验证码 - xixi8820 ASP.NET中App_Code,App_Data等文件夹的作用 javascript 客户端验证 - xixi8820 在DataGrid中模版列显示图片 - xixi8820 上传图片 - xixi8820 页面取物理路径和几种获取asp.net应用程序的路径 模式窗口关闭,并刷新父窗口的方法 跨页面实现多选 用window.location.href实现刷新另个框架页面 听说是个高效的分页存储过程,可以轻松应对百万数据(转) keycode 值 DataGrid点击删除按钮弹出对话框的问题
在Asp.Net中应用DataFormatString
xixi8820 · 2007-12-05 · via 博客园 - xixi8820

DataFormatString 属性语法如下:

DataFormatString="{0:格式字符串}"

我们知道在DataFormatString 中的 {0} 表示数据本身,而在冒号后面的格式字符串代表所们希望数据显示的格式;另外在指定的格式符号后可以指定小数所要显示的位数。例如原来的数据为「1.56」,若格式设定为 {0:N1},则输出为「1.5」。其常用的数值格式如下表所示:

格式字符串   输入                         结果
"{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

其常用的日期格式如下表所示:

格式        说明                       输出格式
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

注意:在ASP.NET 2.0中应设置HtmlEncode为false,否则DataFormatString不起作用
例:<asp:BoundField DataField="SubTime" DataFormatString="{0:f}" HeaderText="SubTime"
            SortExpression="SubTime" HtmlEncode="False" />