只需要表中字段中的日期,而不是完整的日期时间 [英] Need only date in field in a table, not full datetime
问题描述
我正在从数据库中读取信息,实际上我只是对它的显示/排序方式有疑问.我想读一个日期时间,但我只想显示日期,并且希望它从现在到将来进行排序.
I'm reading in info from a database and I'm really just having a problem with how it is displayed/sorted. I want to read in a datetime but I only want to display the date and I want it sorted from now to future.
nextreview.DataType = System.Type.GetType("System.DateTime");
这是我现在所拥有的,但这包括时间,但是我不需要它并且希望它消失.
This is what I have now but this includes the time but I dont need it and want it gone.
以前有过
nextreview.DataType = System.Type.GetType("System.String");
并且在阅读时...将字符串转换为如我所愿的显示
and when reading it in...converting the string to display like I wanted
ToString("MM/dd/yyyy")
这是完美的,除了排序方面.
which was perfect except when it came to sorting.
那么,如何使它显示为"mm/dd/yyyy",但仍被视为日期时间,是否有任何帮助?在网页上使用c#和asp.net
So any help on how to get it to display as "mm/dd/yyyy" but still be treated like a datetime? using c# and asp.net for webpage
以下是对感兴趣的人的代码 http://pastebin.com/WQBUyrQT
Here is the code for those that were interested http://pastebin.com/WQBUyrQT
推荐答案
我只是重做了页面并在gridview中构建了表,而不是在代码中构建了表……最后,这要容易得多.更改了一些代码...但是一切都很好..感谢所有输入
I just redid the page and built the table in gridview rather than building it in the code...in the end it was just much easier..had to change a bit of the code...but it all turned out good..thanks for all the input
这篇关于只需要表中字段中的日期,而不是完整的日期时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!