Your Ad Here
首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > 编程语言 > .NET > C#.NET > DataGrid 日期列的格式(data formatting expression)
【标  题】:DataGrid 日期列的格式(data formatting expression)
【关键字】:DataGrid,data,formatting,expression
【来  源】:http://blog.csdn.net/hufengwen/archive/2006/12/01/1425115.aspx

DataGrid 日期列的格式(data formatting expression)

Your Ad Here

方法1.HTML:

<asp:BoundColumn DataField="date_sche_ship" HeaderText="dateScheduleShip" DataFormatString="{0:dd-MM-yyyy}"></asp:BoundColumn>
                        

方法2.CS:

 

public static string dateFormat(string date)
        {
            
string tempDate = "";
            
string tempStr1 = "";
            
string tempStr2 = "";
            
string tempStr3 = "";
            
int firstIndex, lastIndex,length;

            
if(date != "")
            {
                tempDate 
= date.Trim();
                firstIndex 
= tempDate.IndexOf('/');
                lastIndex 
= tempDate.LastIndexOf('/');

                
if(firstIndex != -1 && lastIndex != -1)
                {
                    length 
= tempDate.Length;

                    tempStr1 
= tempDate;
                    tempStr1 
= tempStr1.Substring(0,firstIndex);
                    tempStr2 
= tempDate;
                    tempStr2 
= tempStr2.Substring(firstIndex + 1,lastIndex - firstIndex - 1);
                    tempStr3 
= tempDate;
                    tempStr3 
= tempStr3.Substring(lastIndex + 1,length - lastIndex - 1);

                    tempDate 
= tempStr3 + "-" + tempStr1 + "-" + tempStr2;
                }
                
else
                    tempDate 
= date;
            }
            
else
                tempDate 
= date;

            
return tempDate;
        }

 

.Net Framework 3.0 学习讨论群 26213556 欢迎加入!!:【上一篇】
如有DXperience源代碼,如何編譯:【下一篇】
【相关文章】
  • 填充DataSet时填充元数据.
  • 微软公司昨天发布SQL Server 2005 Samples and Sample Databases更新版——超过100个的SQL Serve...
  • 英语阅读推荐:主题切换控件 & ExpressionBuilder
  • 在DataGridView控件中一次显示出多个圆饼图的原始程序代码
  • [原创]Object/DataSet Relational Mapping(对象/数据集关系映射)补充代码1
  • oracle10g em Database Control的启动问题修复
  • 全新打造的 DataGrid 控件
  • Mapping SQL and Java data types
  • mapping of SQL Server driver to the JDBC data types
  • Object DataBase --DB4O之旅
  • 【随机文章】
  • 如何處理資料庫中的Null
  • 建销售团队建立周期
  • const 的几点用法
  • 好长时间没有安装informix了!
  • java中对于对话框中空白字段的捕捉
  • oracle调优
  • [HOOPS]segment下的用户信息
  • Boost.Asio 0.37简介(翻译自Boost.Asio 0.37的文档的首页)
  • 如何用asp的jmail发邮件?
  • MySQL 全文搜索
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 bbb软讯网络 All Rigths Reserved.