zoukankan      html  css  js  c++  java
  • GridView列数字、货币和日期的显示格式

    形式 语法 结果 注释
    数字 {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数据绑定控件的模版列时,总要设置显示的格式,这里是我查询一些资料后统计出来的。还有一个常规的选项是用数据库中默认的格式显示。

    protected void DataList1_ItemCreated(object sender, DataListItemEventArgs e)
        
    {
            
    //在创建行的时候触发的事件
            if (e.Item.ItemType == ListItemType.Footer)
            
    {//判断是脚模板
                PlaceHolder pl = new PlaceHolder();
                
    //动态创建一个PlaceHolder用来装页码
                e.Item.Controls.Add(pl);
                
    //把PlaceHolder增加到脚模板中去
                Label lbl = new Label();
                
    //new一个Label,当然,如果这要做页码的话,建议就做成linkbutton了,呵呵
                lbl.Text = "123";

                pl.Controls.Add(lbl);
                
    //把lbl增加到PlaceHolder中去
            }

        }
  • 相关阅读:
    C# json提取多层嵌套到数组-- C# json 数组
    JS中的prototype
    JS_&&||
    js 匿名函数 js-函数定义方法
    js匿名函数确实是个好东西
    JavaScript:undefined!=false之解 及==比较的规则
    Sql 中常用日期转换Convert(Datetime) convert datetime
    jquery设置元素的readonly和disabled
    eWebEditor复制粘贴图片时过滤域名
    java构造函数使用方法总结
  • 原文地址:https://www.cnblogs.com/adam/p/1028841.html
Copyright © 2011-2022 走看看