GridView ASP.NET排序
-
05-07-2019 - |
题
我有一个不会排序的ASP.NET GridView!我确信我错过了一些非常明显的东西。
<强> Page.aspx 强>
<asp:GridView ID="TimeAwayGridView" runat="server" AutoGenerateSelectButton="False"
AutoGenerateEditButton="False" AutoGenerateDeleteButton="False" AllowPaging="False"
AllowSorting="True" CssClass="gridview" OnSorting="TimeAwayGridView_Sorting">
<Columns>
<asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
<asp:BoundField DataField="Hours" HeaderText="Hours" SortExpression="Hours" />
</Columns>
<EmptyDataTemplate>
There are currently no items in this table.
</EmptyDataTemplate>
</asp:GridView>
<强> Page.aspx.cs 强>
protected void TimeAwayGridView_Sorting(object sender, GridViewSortEventArgs e)
{
}
解决方案
Asp.Net Datagrip为您提供排序事件,以及在GridViewSortEventArgs中单击的列的名称,但您必须在TimeAwayGridView_Sorting函数中提供自己的排序实现。这意味着您应该对数据源进行排序并重新绑定数据网格。
不隶属于 StackOverflow