asp.net中的Gridview排序 [英] Gridview Sorting in asp.net
本文介绍了asp.net中的Gridview排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我们点击列标题时我想做的事情是,我必须对数据进行排序,但是我失败了,需要帮助thanx并考虑dnyaneshwar
i want to do when we clik on header of the column then data must be sorted i tried but i fail plese need help thanx and regards dnyaneshwar
推荐答案
按asp.net中的列标题对GridView进行升序降序 [ ^ ]
看看ASP.NET中GridView的新排序样式 [基于列的网格视图排序 [为什么我的gridview的列未单击切换排序方向? [
Sorting GridView By Columns Header In Asp.Net Ascending Descending[^]
A Look at the GridView''s New Sorting Styles in ASP.NET [^]
gridview sorting based on columns[^]
Why doesn''t my gridview''s column click toggle the sort direction?[^]
尝试以下
在设计中:
try below
In design:
OnSortCommand="dguser_SortCommand" AllowSorting="true"
还将SortExpression设置为所有您的ur列,例如以下
SortExpression ="FullName"
InCode背后:
also set SortExpression to all ur columns like below
SortExpression="FullName"
InCode Behind:
public static int numberDiv;
protected void dguser_SortCommand(object source, DataGridSortCommandEventArgs e)
{
try
{
SqlDataReader dr = null;
dr = objHRone.BindUserDetails(ddlFltStatus.SelectedValue);
DataSet ds = new DataSet();
DataTable dt = new DataTable();
dt.Load(dr);
DataView dv = new DataView(dt);
if ((numberDiv % 2) == 0)
dv.Sort = e.SortExpression + " " + "ASC";
else
dv.Sort = e.SortExpression + " " + "DESC";
numberDiv++;
dguser.DataSource = dv;
dguser.DataBind();
}
catch (Exception ex)
{
lblStatusFail.Text = ex.Message.ToString();
}
}
这篇关于asp.net中的Gridview排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文