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中使用JSON进行数据传递
最近在做一个基于JAVA Servlet的WEB应用以及对应的Anroid应用客户端的开发工作. 其中,在接口的访问和数据的传输方面使用的比较多的是使用JSON对象来操作格式化数据:在服务器端采用JS ...
- C#类的继承
public class Animal { public string word=""; //virtual表示虚方法,用以被重写 public virtual void say( ...
- C# 常用日期函数
我想知道取的时期是几月.几日,然后做一些统计,上网找了一些方法. --DateTime 数字型 System.DateTime currentTime=new System.DateTime(); 1 ...
- LeetCode Search a 2D Matrix II
原题链接在这里:https://leetcode.com/problems/search-a-2d-matrix-ii/ Write an efficient algorithm that searc ...
- 使用oracle外部表进行数据泵卸载数据
数据泵卸载Oracle9i引入了外部表,作为向数据库中读取数据的一种方法.Oracle 10g则从另一个方向引入了这个特性,可以使用CREATE TABLE语句创建外部数据,从而由数据库卸载数据.从O ...
- 【Android】首次进入应用时加载引导界面
参考文章: [1]http://blog.csdn.net/wsscy2004/article/details/7611529 [2]http://www.androidlearner.net/and ...
- 跳到下个View
nextWebView = [[ WEBViewController alloc ] initWithNibName : @"WEBViewController" bundle : ...
- mysql 快速生成百万条测试数据
1.生成思路 利用mysql内存表插入速度快的特点,先利用函数和存储过程在内存表中生成数据,然后再从内存表插入普通表中 2.创建内存表及普通表 CREATE TABLE `vote_record_me ...
- SuSE Apache2 VirtualHost Build
1,linux version:openSuSE 12.1 2,add ServerName to DNS(johv.ts.com ,use the same IP) 3,mkdir /srv/www ...
- Java基础之处理事件——使用适配器类(Sketcher 3 using an Adapter class)
控制台程序. 适配器类是指实现了监听器接口的类,但监听器接口中的方法没有内容,所以它们什么也不做.背后的思想是:允许从提供的适配器类派生自己的监听器类,之后再实现那些自己感兴趣的类.其他的空方法会从适 ...