数字 {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-25 10:30:00  
时间 {0:T} 10:30:00

在GridView中操作的时候要注意以下的几个方面(以{0:d}为例)
1.Boundfiled

 <asp:BoundField DataField="Article_Time" DataFormatString="{0:d}" HeaderText="日期" />
<asp:BoundField HeaderText="日期" DataField="Article_Time" HtmlEncode="false" DataFormatString="{0:yyyy-MM-dd}"></asp:BoundField>

注意必须将HtmlEncode设置为false

2.模板列

 <asp:TemplateField HeaderText="日期">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Article_Time") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%# Bind("Article_Time", "{0:d}") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
 <asp:TemplateField HeaderText="日期">
<ItemTemplate>
<%#Eval("Article_Time", "{0:yyyy-MM-dd}")%>
</ItemTemplate>
</asp:TemplateField>

GridView中的日期处理的更多相关文章

  1. 在Gridview 中 对日期格式的控制

    在数据库中保存日期格式的时候,我们需要在客户端的显示有自己的要求 这就需要对 datatime 类型的数据进行控制,使之显示为你需要的格式 数据库中 如果不对其进行控制,显示的格式为 当在前端页面上进 ...

  2. asp:gridview 中显示日期格式

    boundfield中应该这样设置: <asp:BoundField HeaderText="发表时间" DataField="PostTime" Htm ...

  3. GridView中显示时间日期格式问题

    以下都是GridView基本常用的日期,时间格式 形式 语法 结果 注释 数字 {0:N2} 12.36   数字 {0:N0} 13   货币 {0:c2} $12.36   货币 {0:c4} $ ...

  4. Dev gridView中设置自适应列宽和日期显示格式、金额的显示格式

    在Dev GridView控件中,数据库中表数据日期都是长日期格式(yyyy-MM-dd HH:mm:ss),但显示在控件变成短日期格式(yyyy-MM-dd),金额显示要显示精确的数值, 比如80. ...

  5. 如何将excel导入到数据库中并在gridview中显示

    在页面上导入个excel文件,将该excel中的数据导入到数据库中,并且在页面的gridview中把数据显示出来. .在Asp.net中怎样将Excel文件中的数据导入到GridView中呢? 首先我 ...

  6. Gridview中Datakeys 通过主键取得各列的值。

    首先在初始化Gridview时候定义主键的数组. GridViewTeacherStudent.DataKeyNames=new string[] {"courseId",&quo ...

  7. Repeater 和 GridView 中数据格式化

    GridView中显示两位小数: <asp:BoundField DataField="investmoney" DataFormatString="{0:f2}& ...

  8. [转载]SQL语句中的日期计算

    1. 本月的第一天SELECT  DATEADD(mm,  DATEDIFF(mm,0,getdate()),  0) 2. 本月的最后一天SELECT  dateadd(ms,-3,DATEADD( ...

  9. 实现CheckBox的三种选中状态(全选、半选、不选)在GridView中模拟树形的功能

    度娘了很多帖子,只说三种状态要用图片替换来做,但没找到有用的例子,被逼自己写了一个 三方控件肯定是很多的,如jstree,可以直接用 由于公司的UDS限制,不能上传图片,只能文字说明了. 就是要在gr ...

随机推荐

  1. [Vue @Component] Load Vue Async Components

    Vue provides a straight-forward syntax for loading components at runtime to help shave off initial b ...

  2. Oracle 用户管理(二)

    1    给某人赋予"系统权限"     SQL> grant connect to aobama with admin option     意思是将admin的连接数据库 ...

  3. win32 API函数

    cozy的博文 win32 API函数大全   (2008-03-15 16:28) 分类: 个人日记 1. API之网络函数 WNetAddConnection 创建同一个网络资源的永久性连接 WN ...

  4. [Codeforces Round49F] Session in BSU

    [题目链接] http://codeforces.com/contest/1027/problem/F [算法] 二分图匹配 [代码] #include<bits/stdc++.h> #p ...

  5. 收集主机OS相关数据

    #!/usr/bin/ksh touch hostinfo$(date +%Y%m%d).csv filename=hostinfo$(date +%Y%m%d).csv >${filename ...

  6. MSP430:中断简介

    (5).中断应用程序举例(外部中断): void interrupt_initial() { P1DIR&=~BIT7;      //P1.7为输入 P1IE|=0x80;      //P ...

  7. 常见的几种异常类型Exception

    转自:https://blog.csdn.net/niceworkgogogo/article/details/71746208 算数异常类:ArithmeticExecption 空指针异常类型:N ...

  8. shell脚本-循环选择语句

    shell脚本-循环选择语句 过程式编程语言: 顺序执行 选择执行 循环执行 注:条件中的变量,可以在执行语句中使用,不用在加上"$". if语句 根据命令的退出状态来执行命令 单 ...

  9. git期末总结(转载)

    转自:http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/00137586810169 ...

  10. E20170807-mk

    literal adj. 照字面的; 原义的; 逐字的; 平实的,避免夸张;