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

推荐订阅源

P
Proofpoint News Feed
WordPress大学
WordPress大学
Help Net Security
Help Net Security
Jina AI
Jina AI
Security Latest
Security Latest
Y
Y Combinator Blog
Project Zero
Project Zero
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
GbyAI
GbyAI
Know Your Adversary
Know Your Adversary
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
NISL@THU
NISL@THU
Cisco Talos Blog
Cisco Talos Blog
博客园 - 司徒正美
MyScale Blog
MyScale Blog
Cyberwarzone
Cyberwarzone
D
Docker
T
The Blog of Author Tim Ferriss
G
Google Developers Blog
C
CERT Recently Published Vulnerability Notes
B
Blog
L
LangChain Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
SecWiki News
SecWiki News
The Hacker News
The Hacker News
C
Check Point Blog
L
Lohrmann on Cybersecurity
V2EX - 技术
V2EX - 技术
S
Securelist
T
Threat Research - Cisco Blogs
Stack Overflow Blog
Stack Overflow Blog
TaoSecurity Blog
TaoSecurity Blog
云风的 BLOG
云风的 BLOG
Latest news
Latest news
人人都是产品经理
人人都是产品经理
L
LINUX DO - 最新话题
Application and Cybersecurity Blog
Application and Cybersecurity Blog
The Register - Security
The Register - Security
Webroot Blog
Webroot Blog
Simon Willison's Weblog
Simon Willison's Weblog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Microsoft Security Blog
Microsoft Security Blog
AWS News Blog
AWS News Blog
C
Cybersecurity and Infrastructure Security Agency CISA
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
小众软件
小众软件
T
Tailwind CSS Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
宝玉的分享
宝玉的分享
O
OpenAI News

博客园 - xixi8820

输入框验证输入数字的js 关于VS2005中GridView的自定义分页,单选、多选、排序、自增列的简单应用(转载的) 使用t-sql从身份证号中提取生日(转自别人,个人学习收藏用) 一个最简单的登录例子 js中setTimeout与setInterval的区别 js将html中的内容导出word、或者excel文件的方法 javascript 获得指定日期的临近日期的方法 asp.net 2.0 生成验证码 ASP.NET中App_Code,App_Data等文件夹的作用 javascript 客户端验证 在DataGrid中模版列显示图片 上传图片 页面取物理路径和几种获取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" />