设定BoundField的DataFormatString,通常有以下几种 DataFormatString= "{0:C}" 货币,货币的格式取决于当前Thread中Culture的设置 DataFormatString= "{0:E}" 科学计数法 DataFormatString= "{0: P}" 百分比 DataFormatString= "{0:F?}" 小数点后几位 DataFormatString= "{0:d}" M/d/yyyy 如 10/30/2008 DataFormatString= "{0:f}" 长日期,短时间。dddd,MMMM dd,yyyy HH:mm aa 如, Monday, January30, 2008 10:00am DataFormatString= "{0: D}" 长日期。dddd,MMMM dd,yyyy 如: Monday,January 30,2008 DataFormatString= "{0:F}" 长日期,长时间 dddd,MMMM dd,yyyy HH:mm:ss aa DataFormatString= "{0: s}" ISO 标准时间。yyyy-MM-ddTHH:mm:ss,如: 2008-01-30T10:20:55am DataFormatString= "{0:M}" 月份和日期 MMMM dd,如January30 DataFormatString= "{0:G}" 一般格式 M/d/yyyy HH:mm:ss aa ----------------------------------------------------------------- 格式字符串 输入 结果 "{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

<%#    String.Format("{0:yyyy-MM-dd} ", Eval("EffectiveDate "))%>

<%#    String.Format("{0:yyyy-M-d} ", DataBinder.Eval(Container.DataItem, "EffectiveDate "))%>

GridView格式化数据DataFormatString的更多相关文章

  1. Gridview利用DataFormatString属性设置数据格式

    首 先把Gridview的AutoGenerateColumns属性设为False(默认是False),DataField选择相应的字段,特别需要注 意的是要把需要设置的字段的HtmlEncode属性 ...

  2. GridView的DataFormatString格式化字符串

    DataFormatString="{0:格式字符串}" 0:代表字段本身 冒号后面的代表希望的格式 比如 {0:yyyy-MM-dd}  显示的时间类型就是2016-04-11 ...

  3. GridView和DataFormatString 日期格式 精确小数点后位数

    如果DataFormatString无效,请添加属性 HtmlEncode = "false" --------------------------------------- Da ...

  4. gridview DataFormatString 属性设置须知

    设置 DataFormatString 进行格式化数据时默认情况下是不会起作用的还有设置HtmlEncode = "false" 具体为什么?以下几点1. 在GridView中的a ...

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

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

  6. 一些ASP.NET的小知识点

    DataFormatString="{0:格式字符串}" 我们知道在DataFormatString 中的 {0}表示数据本身,而在冒号后面的格式字符串代表所们希望数据显示的格式; ...

  7. asp.net 中日期的格式化显示的方法

    在Asp.net 中经常使用日期,在不同的场合,对日期的显示方式有不同的要求,为此,自己总结了一些日期格式化的方式,仅供学习参考使用: C#格式化日期时间 DateTime dt = DateTime ...

  8. ASP.NET的gridview设置数据格式(DataFormatString="{}") 2011年04月08日 16:26:00 阅读数:5318 标签: asp.net datagrid integer asp date strin

    select convert(numeric(8,2),round(UnTaxAmount,2))as UnTaxAmount from View_SaleVoiceselect   cast(UnT ...

  9. Eval() 中数据格式化或格式化数据

    <%# Eval("SchoolEnd") == DBNull.Value ? "" : Convert.ToDateTime(Eval("Sc ...

随机推荐

  1. 武汉科技大学ACM :1007: A+B for Input-Output Practice (VII)

    Problem Description Your task is to Calculate a + b. Input The input will consist of a series of pai ...

  2. 在linux下用tomcat部署java web项目的过程与注意事项(转)

    一.安装JDK到http://www.oracle.com/technetwork/java/javase/downloads/index.html下载Java SE 6 Update 27根据操作系 ...

  3. tomcat可以访问到软链接设置

    tomcat/conf/context.xml设置<Context allowLinking="true"> 就可以啦.

  4. PHPCMS 标签与解析小记_Jason

    Content模块下的标签解析:phpcms\modules\content\classes\content_tag.class.php 推荐位:public function position

  5. Mac下安装MySQL-python

    前提系统中已安装python.mysql数据库: 第一步(终端输入): $ export PATH=$PATH:/usr/local/mysql/bin 第二步(终端输入): $ sudo pip i ...

  6. RTC 之 ARM7 2136 ARM9之2410

    RTC 的原理都是一样的,但计数过程中的计数换算却不相同: ARM9 直接出来的是BCD 码,也就是0x30   就是30秒,没有换算了,而ARM7则不同,他是直接计数的,十进制的30秒则是0x1E, ...

  7. DDMS中File Explorer无法查看data/data文件解决办法

    http://www.cnblogs.com/smyhvae/p/3881477.html  找了个连接 问题描述:最近在学习Android SQLite中的SQLiteOpenHelper,使用SQ ...

  8. ESSENTIAL ENGLISH SLANG

    airhead: stupid person. ace: excellent, great. Adam and Eve - Rhyming Slang for 'believe'. aggro - s ...

  9. Shell continue循环

    [oracle@june ~]$ cat continue.sh for i in a b c d e f g do if [ "$i" = "c" ] the ...

  10. Day01_UNIX基础及VI简介

    2013年09月29日 星期日 11时35分58秒 Linux 是一个区别于Windows的操作系统 Linux 是一个多用户的操作系统 Linux 系统通过账号区分不同的用户 在使用Linux系统的 ...