请问怎样让datagrid绑定的datetime类型的字段,只显示yyyy-mm-mm格式的时间?

HISOKAa 2004-04-29 04:44:15
我现在显示出来是“2004-4-1 0:00:00”这种格式的时间,而我根本不需要精确到一天里的具体时间,只要年月日就可以了,怎么样才能把0:00:00去掉,不显示?

谢谢
...全文
92 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
ltlx 2004-04-29
  • 打赏
  • 举报
回复
在datagrid的属性生成器日期列的数据格式表达式中写上{O:yyyy-MM-dd} 就可以了
lingling82 2004-04-29
  • 打赏
  • 举报
回复
<asp:BoundColumn DataField="字段名" HeaderText="日期" DataFormatString="{0:d}</asp:BoundColumn>

如果是模板列<%# DataBinder.Eval(Container, "DataItem.Workroom_date","{0:d}")%>
smx717616 2004-04-29
  • 打赏
  • 举报
回复
Format expression Applied to this data type Description
Price: {0:C}
Note The {0} is a zero, not the letter O. numeric/decimal Displays the literal "Price:" followed by numbers in currency format. The currency format depends on the culture setting specified via the culture attribute on the Page directive or in the Web.config file.
{0:D4} integer (Cannot be used with decimal numbers.) Integers are displayed in a zero-padded field four characters wide.
{0:N2}% numeric Displays the number with 2-decimal place precision followed by the literal "%".
{0:000.0} numeric/decimal Numbers rounded to one decimal place. Numbers less than three digits are zero padded.
{0:D} date/datetime Long date format ("Thursday, August 06, 1996"). Date format depends on the culture settting of the page or the Web.config file.
{0:d} date/datetime Short date format ("12/31/99").
{0:yy-MM-dd} date/datetime Date in numeric year-month-day format (96-08-06).
HISOKAa 2004-04-29
  • 打赏
  • 举报
回复
up

62,243

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧