通过单击标题列在Gridview中对数据进行排序

编程入门 行业动态 更新时间:2024-10-28 17:13:52
本文介绍了通过单击标题列在Gridview中对数据进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

如何通过单击gridview的标题表头来对Gridview中的数据进行排序 ================================================== === 尊敬的朋友, 我有一个Gridview,其中显示了成千上万条记录. 通过单击gridview的标题列对数据进行排序.我也给了允许排序为TRUE. 在gridview的第一页中,它正在排序,因此当我单击分页时,它不会在另一页中排序(为此,我再次需要单击标题列) 所以我不想点击任何页面的标题.一旦我单击第一个标题,它就必须对每个页面进行排序. 请帮忙.

解决方案

,这样您就可以进行了. 1)将SortExpression添加到GridView模板,并在gridview属性中设置Allow Sorting = True 2)创建on函数,该函数将为您提供排序表达式并将其存储在您的视图状态或根据您的要求的任何其他内容中.除了可以保持排序方向外,还可以使用视图状态或其他方式来维护它. 3)因此,在绑定网格时,您可以将该视图状态值用于排序表达式以及排序方向. 4)因此,当您触发下拉菜单选择的索引更改以按学生姓名排序时,还要将排序表达式的视图状态值设置为学生姓名,并将排序方向设置为< code> asc</code>.或< code> desc</code>. 5)当您要更改页面索引时,请使用先前存储的排序表达式和方向来对数据视图进行排序,以保持排序. 可以在直接查询中使用< code>默认视图</code>来代替按原因排序. < code>数据表</code>的并在该视图上应用Sorting,最好是进行gridview排序. 您可以参考此链接... 排序GridView 1 [ ^ ] 排序GridView 2 [ ^ ]

<您好, 请参考以下链接: msdn.microsoft/en-us/library/system.web.ui.webcontrols.gridview.sorting.aspx [ ^ ] 分类和分页通用GridView [ ^ ] 用户GridView ASP.NET [ ^ ] GridView分页和排序 [ ^ ] --Amit

HOW TO SORT the DATA in Gridview by clicking header cloumn of gridview ===================================================== Dear Friends, I have a Gridview with thousand of records displayed in it. am sorting data by clicking header columns of gridview. also i gave allow sorting to TRUE. in the first page of gridview it is sorting, so when i click on paging it doesnot sort in another page (for this again i need to click on header column) so i dont want to click header for ever page. once i click on first header , it must sort for every page. Please help.

解决方案

so you can go like this. 1) Add SortExpression to GridView Template as well as set Allow Sorting = True in gridview properties 2) create on function which will give you sort expression and store it in your view state or any thing else as per your requirement. As well as it will also maintain the sort direction, you can also maintain it with view state or other way. 3) so while binding grid you can use that view state value for sort expression as well as sort direction. 4) so while you fire your dropdown selected index change for sorting by student name then also set the value of view state for sort expression as student name and sort direction as <code>asc</code> or <code>desc</code>. 5) while you are going to change your page index as that time sort your data view using previously stored sort expression and direction to maintain sorting. Instead of using order by cause in direct query you can use <code>Default View</code> of <code>data-table</code> and apply Sorting on that view, it is better idea for gridview sorting. you can refer this links... Sorting GridView 1[^] Sorting GridView 2[^]

Hi, Refer the links below: msdn.microsoft/en-us/library/system.web.ui.webcontrols.gridview.sorting.aspx[^] Sorting and Paging of an Generic GridView[^] Userful GridView ASP.NET[^] GridView Paging and Sorting[^] --Amit

更多推荐

通过单击标题列在Gridview中对数据进行排序

本文发布于:2023-11-04 06:43:57,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1557227.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:中对   单击   标题   数据   Gridview

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!