【发布时间】:2013-10-03 10:24:31
【问题描述】:
我正在从数据库中获取带有时间戳的日期时间字段。
我的网格有一个自动生成的列。
我正在我的.cs 页面中对其进行格式化
dsWorkItems.Tables[0].Rows[count]["Date"] =
!string.IsNullOrEmpty(dsWorkItems.Tables[0].Rows[count]["Date"].ToString()) ?
((DateTime)(dsWorkItems.Tables[0].Rows[count]["Date"])).ToShortDateString(): "";
快速观看我得到了
((DateTime)(dsWorkItems.Tables[0].Rows[count]["Date"])).ToShortDateString() as 9/26/2013
但在网格中我得到9/26/2013 12:00:00 AM 但我想在网格中显示9/26/13
还有一件事是可以在单元格工具提示中显示来自数据库的完整日期时间戳值..
我试过了
dsWorkItems.Tables[0].Columns["Date"].DefaultCellStyle.Format = "MM/dd/yy";
但 DefaultCellStyle 程序集丢失我添加了 System.Windows.Form 但仍然没有工作
【问题讨论】:
-
您显示了两个不同的列,您要更改的一个似乎是名称为
Date的字符串列,网格中显示的另一个DateTime列是MODIFIED。这很令人困惑,请澄清。 -
对不起,我的错误..我正在修改它。它只是杀了我..
标签: c# asp.net gridview grid dataset