DataFormatString在GridView的列不工作 [英] DataFormatString not working in gridview column

查看:112
本文介绍了DataFormatString在GridView的列不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ASP.NET 3.5应用程序在一个页面的GridView。

I have an ASP.NET 3.5 application with a gridview in a page.

我要格式化的列作为一个日期时间之一。我试过:

I want to format one of the columns as a datetime. I've tried:

<asp:BoundField DataField="StatusDate" HeaderText="as of" SortExpression="StatusDate" DataFormatString="{0:d}" />

问题是,无论我做什么,我从来没有格式化改变。我试过其他的日期格式字符串(一般情况下,排序,的longdate,不胜枚举),但此列的格式不会改变。

The problem is no matter what I do, my formatting never changes. I've tried the other date formatting strings (general, sortable, longdate, the list goes on), but the format of this column never changes.

我不觉得我做错什么,但是这是推动我坚果当我尝试基于此列进行排序。因为默认值是格式化的列作为一个字符串,它不正确地排序,当我排序的列标题。

I don't think I'm doing anything wrong, but this is driving me nuts when I try to sort based on this column. Because the default is formatting the column as a string, it doesn't sort correctly when I sort by the column header.

任何人都看到了这一点,并有某种解决办法呢?我见过的文章提的添加自定义排序方法,但我想,如果我能坚持到外的现成功能。

Anyone seen this and have some kind of workaround? I've seen articles mentioning adding a custom sort method, but I'm trying to stick to out-of-the-box functionality if I can.

推荐答案

由于该列的源数据类型不是日期时间!

Because the data type of the source of that column is not datetime!

这篇关于DataFormatString在GridView的列不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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