All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
使用 jQuery(Ajax)MySQL实现自动完成功能_[AJAX教程]
怎样正确理解.NET和SQL Server中“空值”_[SQL Server教程]
.NET框架类库中的定时器类的使用_.net资料_编程技术
PHP中使用XML-RPC构造Web,Service简单入门_php资料_编程技术
delphi获取Windows目录
c#中GDI+图形图像:GDI+中的区域使用方法
SQL语言快速入门之三_mssql学习_编程技术
.NET基础知识-公共语言运行时_[Asp.Net教程]
c#中类的方法定义,参数,使用,重载
在ASP.NET程序中运用JavaScript_[Asp.Net教程]
Reading number is top 10 pictures
Nine school beauty star those gossip matters
毕姥爷事件,告诉你6条真理
Sora aoi mirror memorial classics4
A letter to parents choose world of warcraft seven big reason
寒流来了
Beauty shocked Japan Tokyo motor show model
So beauty, will let you spray blood1
Photographed the passion of the clients and prostitutes in the sex trade picture1
迷人的靓女
俄罗斯台球天后惊艳魅惑1
Download software ranking
I'm come from Beijing2
变速齿轮3.26
尖东毒玫瑰B
Unix video tutorial3
传奇私服架设教程-chm
Unix video tutorial2
Boxer's Top ten classic battle7
仙剑奇侠传98版歌曲
Photoshop 8.0图象编辑软件
Sora aoi - one of more PK
归海一刀 published in(发表于) 2014/1/30 1:02:12 Edit(编辑)
GridView绑定模板格式化日期总结_[Asp.Net教程]

GridView绑定模板格式化日期总结_[Asp.Net教程]

GridView绑定模板格式化日期总结_[Asp.Net教程]

问题描述:GridView模板列绑定数据库中的T_LogDate字段,然后读取系统时间。代码如下:


<%# Eval("T_LogDate").ToString() %>
显示结果是:2008-01-26 14:03:59;我现在要就显示2008-01-26。
很简单,看下面代码:

<%# Eval("T_LogDate", "{0:yyyy-MM-dd}").ToString()%>
大功告成!
注意:此功能只针对模板列控件。

关于格式化问题,还有一种思路就是从数据库中读取相关字段,在SQL语句中格式化输出。

代码如示:select convert(varchar(10),字段名) as 时间 from 表名
比如上面例子就应该这样写:select convert(varchar(1000),T_LogDate,105) as 时间 from T_Information
注意:当数据量比较大的时候,效率是个问题。一般不推荐!
总结一下格式:
形式
语法
结果
注释
数字
{0:N2}
12.36
数字
{0:N0}
13
货币
{0:c2}
12.36
货币
{0:c4}
12.3656
货币
"¥{0:N2}"
¥12.36
科学计数法
{0:E3}
1.23E+001
百分数
{0:P}
12.25%
P and p present the same.
日期
{0:D}
2006年11月25日
日期
{0:d}
2006-11-25
日期
{0:f}
2006年11月25日 10:30
日期
{0:F}
2006年11月25日 10:30:00
日期
{0:s}
2006-11-26 10:30:00
时间
{0:T}
10:30:00
在设置GridView数据绑定控件的模版列时,总要设置显示的格式,这里是我查询一些资料后统计出来的。还有一个常规的选项是用数据库中默认的格式显示。

来源:http://blog.csdn.net/codeshark





添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.