Retrive Date Format表单数据库 [英] Retrive Date Format form database

查看:97
本文介绍了Retrive Date Format表单数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在asp.net中创建了一个应用程序,其中我使用了ajaxtoolkit日历扩展器,日期格式为mm / dd / yyyy,我以yyyymmdd格式插入数据库。

我怎么样以mm / dd / yyyy格式显示gridview中的数据。

I have created a application in asp.net in which i have used ajaxtoolkit calender extender and the date format is mm/dd/yyyy and i am inserting into database in yyyymmdd format.
how i display the data in gridview in mm/dd/yyyy format.

推荐答案

Sure, if you're using a BoundField, simply do as follows:

<asp:boundfield datafield="Your_Date_Column" dataformatstring="{0:MM/dd/yyyy, yyyy}" htmlencode="false" /> Just make sure you set the HtmlEncode attribute to False or it won't work.


在.aspx的网格日期列中使用它:

Use this in your date column of grid in .aspx :
<%# Convert.ToDateTime(Eval("MyDate")).ToString("dd MMM yyyy")%>






Or

<%# Eval("MyDate", "{0:dd MMM yyyy}")%>





-KR



-KR


在sql server中你可以写得像这个..



convert(varchar(10),date,103)



http://www.sql-server-helper.com/tips/date-formats.aspx [ ^ ]
in sql server you can write like this..

convert(varchar(10),date,103)

http://www.sql-server-helper.com/tips/date-formats.aspx[^]


这篇关于Retrive Date Format表单数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆