Repeater 时间格式化
Repeater 时间格式化
<%# Eval("AboutDate","{0:yyyy-MM-dd hh:mm:ss}")%> 个人认为最好用最灵活的
在Repeater控件中绑定的一个数据中,如:
<td><%#Eval("dates") %></td>
由于数据库中的时间字段格式是:2005-12-16 11:52:01
而我在Repeater控件中要的日期格式是:2005-12-16
只需要这样写就ok了
<td> <%# Eval("dates","{0:yyyy-MM-dd}")%> </td>
======================================================================
转载以下有关日期类型格式化显示的文章以供学习:
1.绑定时格式化日期方法:
<ASP:BOUNDCOLUMN DATAFIELD= "JoinTime " DATAFORMATSTRING= "{0:yyyy-MM-dd} " >
<ITEMSTYLE WIDTH= "18% " > </ITEMSTYLE >
</ASP:BOUNDCOLUMN >
2.数据控件如DataGrid/DataList等的件格式化日期方法:
e.Item.Cell[0].Text = Convert.ToDateTime(e.Item.Cell[0].Text).ToShortDateString();
3.用String类转换日期显示格式:
String.Format( "yyyy-MM-dd ",yourDateTime);
4.用Convert方法转换日期显示格式:
Convert.ToDateTime("2005-8-23").ToString
("yyMMdd",System.Globalization.DateTimeFormatInfo.InvariantInfo); //支持繁体数据库
5.直接用ToString方法转换日期显示格式:
DateTime.Now.ToString("yyyyMMddhhmmss");
DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss")
6.只显示年月
DataBinder.Eval(Container.DataItem,"starttime","{0:yyyy-M}")
7.显示时间所有部分,包括:年月日时分秒
<asp:BoundColumn DataField="收款时间" HeaderText="收款时间"
DataFormatString="{0:yyyy-MM-dd HH24:mm:ss}">
</asp:BoundColumn>
********************************************************************************************************************************************
ASP.NET GridView,DataList,Repeater日期格式显示
在Repeater控件中绑定的一个数据中,如:
<%#DataBinder.Eval(Container.DataItem,"Title")%>
由于数据库中的时间字段格式是:2005-12-16 11:52:01 而我在Repeater控件中要的日期格式是:2005-12-16 只需要加上:
<%#Convert.ToDateTime(DataBinder.Eval(Container.DataItem,"PostTime")).ToShortDateString()%>
就可以达到效果了! 简化:<%#Convert.ToDateTime(Eval("intime")).ToShortDateString()%> <%#Eval("PubDate","{0:yyyy-MM-dd}")%> Repeat控件自动编号代码:<%# Container.ItemIndex + 1%> 如<asp:Repeater ID="rptService" runat="server">
<ItemTemplate> <div class="service_box">
<p><span><%# Container.ItemIndex + 1%></span> <%#Eval("Title") %></p>
<p><%#Eval("Content") %></p>/div> </ItemTemplate>
</asp:Repeater>
Repeater 时间格式化的更多相关文章
- strftime 日期时间格式化
strftime() 函数根据区域设置格式化本地时间/日期,函数的功能将时间格式化,或者说格式化一个时间字符串. size_t strftime(char *strDest,size_t maxsiz ...
- javascript 时间格式化
添加扩展 //时间格式化扩展Date.prototype.format = function(format){ var o = { "M+" : this.getMonth()+1 ...
- js时间格式化
const formatDate = timestamp => { const date = new Date(timestamp); const m = date.getMonth() + 1 ...
- js对特殊字符转义、时间格式化、获取URL参数
/*特殊字符转义*/ function replace_html(str) { var str = str.toString().replace(/&/g, "&" ...
- 特殊字符转义&时间格式化&获取URL参数
/*特殊字符转义*/ function htmlspecialchars (str) { var str = str.toString().replace(/&/g, "&& ...
- 【AspNetCore】【WebApi】扩展Webapi中的RouteConstraint中,让DateTime类型,支持时间格式化(DateTimeFormat)
扩展Webapi中的RouteConstraint中,让DateTime类型,支持时间格式化(DateTimeFormat) 一.背景 大家在使用WebApi时,会用到DateTime为参数,类似于这 ...
- EasyUI Datagrid Datetime(EasyUI DataGrid 时间格式化)
EasyUI DataGrid 时间格式化 方法一: var Common = { //EasyUI用DataGrid用日期格式化 TimeFormatter: function (value, re ...
- js Date 时间格式化的扩展
js Date 时间格式化的扩展: Date.prototype.format = function (fmt) { var o = { , //月 "d+": this.getD ...
- SqlServer时间格式化
最近用的SqlServer比较多,时间格式化老是忘记,现整理如下:(来源于网上,具体来源地址忘记了,归根到底MSDN吧) SELECT CONVERT(varchar(50), GETDATE(), ...
随机推荐
- Java HashMap、LinkedHashMap
如果需要使用的Map中的key无序,选择HashMap:如果要求key有序,则选择TreeMap. 但是选择TreeMap就会有性能问题,因为TreeMap的get操作的时间复杂度是O(log(n)) ...
- handler机制的原理
andriod提供了Handler 和 Looper 来满足线程间的通信.Handler先进先出原则.Looper类用来管理特定线程内对象之间的消息交换(MessageExchange). 1)Loo ...
- Solr搜索基础
本例我们使用类库和代码均来自: http://www.cnblogs.com/TerryLiang/archive/2011/04/17/2018962.html 使用C#来模拟搜索.索引建立.删除. ...
- [LeetCode]题解(python):043-Multiply Strings
题目来源 https://leetcode.com/problems/multiply-strings/ Given two numbers represented as strings, retur ...
- MSP430之Hello World!
//#include "io430.h" #include "MSP430G2553.h" int main( void ) { volatile unsign ...
- http://blog.sina.com.cn/s/blog_705cc5dd01012ehb.html
http://blog.sina.com.cn/s/blog_705cc5dd01012ehb.html
- 微信支付开发(12) 认清微信支付v2和v3
微信支付现在分为v2版和v3版 2014年9月10号之前申请的为v2版,之后申请的为v3版. V2版中的参数有AppIDAppSecret支付专用签名串PaySignKey商户号PartnerID初始 ...
- PHP中用下划线开头的变量含义
http://blog.csdn.net/zlking02/article/details/6752256 一个下划线是私有变量以及私有方法两个下划线是PHP内置变量. https://segment ...
- Windows 7 / Windows 10 安装 IPX/SPX
以我的系统为例: Windows 7/10 x64 首先下载 NWLINK IPX/SPX 驱动(这是 Microsoft 对 IPX/SPX 的实现.) http://pan.baidu.com/s ...
- C#处理JSON数据
每次写博客,第一句话都是这样的:程序员很苦逼,除了会写程序,还得会写博客!当然,希望将来的一天,某位老板看到此博客,给你的程序员职工加点薪资吧!因为程序员的世界除了苦逼就是沉默.我眼中的程序员大多都不 ...