在asp.net中的Gridview中排序项目 [英] sort items in gridview in asp.net

查看:99
本文介绍了在asp.net中的Gridview中排序项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何根据其日期时间列对gridview的项进行排序.
我尝试使用sqlcommand(按[date] desc排序),但是它不起作用.
任何建议... ??请??

how to sort items of gridview according to datetime coloumn of it.
i tried it using sqlcommand (order by [date] desc) but it doesnt work.
any suggestion...?? pls??

推荐答案

您的数据来源是什么?您如何使用GridView出价?如果直接与GridView绑定,则必须同时获取日期和时间"字段.
您需要做的是,对于GridView cheanhe中的Date列,使用以下属性DataFormatString={0:dd- MMM-yyyy} HtmlEncode="false".
希望这能解决您的问题.顺便说一句,此处指定的日期格式可能与您期望的有所不同.因此,您必须提供适当的DataFormatString.
您也可以 http://forums.asp.net/p/1223734/2190227找到有趣的线程. aspx#2190227 [ ^ ]
What is your source of Data ? How are you biding it with GridView ? If you are directly binding with GridView, you must be getting Both Date and Time field.
What you need to do is, for the Date Column in GridView cheanhe the below properties DataFormatString="{0:dd- MMM-yyyy}" HtmlEncode="false".
I hope This will resolve your problem. BTW, The Date Format specified here is might be something different than you are expecting. So you have to provide the proper DataFormatString.
You can find this thread interesting as well http://forums.asp.net/p/1223734/2190227.aspx#2190227[^]


这篇关于在asp.net中的Gridview中排序项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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