gridview的sort_GridView排序:SortDirection始终升序
我有一個(gè)gridview,當(dāng)用戶單擊標(biāo)題時(shí),我需要對(duì)其元素進(jìn)行排序。
它的數(shù)據(jù)源是一個(gè)List對(duì)象。
aspx是這樣定義的:
AutoGenerateColumns="false" Width="780" runat="server"? OnSorting="grdHeader_OnSorting" EnableViewState="true">
后面的代碼是這樣定義的:
第一次加載:
protected void btnSearch_Click(object sender, EventArgs e)
{
List items = GetPeriodStatusesForScreenSelection();
this.grdHeader.DataSource = items;
this.grdHeader.DataBind();
}
當(dāng)用戶點(diǎn)擊標(biāo)題時(shí):
protected void grdHeader_OnSorting(object sender, GridViewSortEventArgs e)
{
List items = GetPeriodStatusesForScreenSelection();
items.Sort(new Helpers.GenericComparer(e.SortExpression, e.SortDirection));
grdHeader.DataSource = items;
grdHeader.DataBind();
}
我的問(wèn)題是e.SortDirection始終設(shè)置為升序。
我的網(wǎng)頁(yè)使用了類似的代碼,并且運(yùn)行良好,e.SortDirection在升序和降序之間交替。
我做錯(cuò)了什么 ?
總結(jié)
以上是生活随笔為你收集整理的gridview的sort_GridView排序:SortDirection始终升序的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: java程序经过编译后会产生byte c
- 下一篇: uni的numberbox怎么用_uni