我如何...在gridview控件中仅将日期时间格式显示为日期? [英] How do I...show a datetime format into only date in gridview control ?

查看:100
本文介绍了我如何...在gridview控件中仅将日期时间格式显示为日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我将日历从calander放入gridview

时它会随时间显示

i只想在gridview中显示日期

解决方案

在GridView中,您可以为每个列指定一种格式...将正确的格式设置为日期列,它将按需显示...

 <   asp:boundfield     datafield   =  Your_Date_Column    dataformatstring   =  {0:dd / MM / yyyy}    /  >  


不幸的是在C#中我们没有一个叫做的类型达TE。我们可以做的是我们可以将datetime转换为字符串,并且只能以字符串格式显示日期。



 dateTime.ToString(< span class =code-string>  yyyy-MM-dd


试试这个

 Date.ToString(  YYYY-MM-DD); 


when i put a date from calander into gridview
it will show with time also
i just only want to show only date in gridview

解决方案

In GridView you can assign a format to every column...Set the proper format to your date column and it will be displayed as wanted...

<asp:boundfield datafield="Your_Date_Column" dataformatstring="{0:dd/MM/yyyy}" />


Unfortunately in C# we do not have a type called Date. What we can do is we can convert the datetime to string and can display only date in string format.

dateTime.ToString("yyyy-MM-dd") 


try this

Date.ToString("yyyy-MM-dd");


这篇关于我如何...在gridview控件中仅将日期时间格式显示为日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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