C# 带绑定字段的Gridview排序
排序不起作用。我缺少什么?在排序事件处理程序中,可以更改数据表的排序属性C# 带绑定字段的Gridview排序,c#,asp.net,.net,C#,Asp.net,.net,排序不起作用。我缺少什么?在排序事件处理程序中,可以更改数据表的排序属性 <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" AllowPaging="true" AllowSorting="true" PageSize="10" DataKeyNames="CategoryID" onselectedindexchanged="GridView1_Selecte
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
AllowPaging="true" AllowSorting="true" PageSize="10" DataKeyNames="CategoryID"
onselectedindexchanged="GridView1_SelectedIndexChanged"
GridLines="Vertical" onrowediting="GridView1_RowEditing"
onrowcancelingedit="GridView1_RowCancelingEdit"
onrowupdating="GridView1_RowUpdating" onsorted="GridView1_Sorted"
onsorting="GridView1_Sorting">
<Columns>
<asp:BoundField DataField="categoryid" HeaderText="ID" SortExpression="CategoryID" />
</Columns>
</asp:GridView>
如何处理onsorting事件?该事件句柄中没有任何内容。如何使用
SQLDataSource
或DataSet
绑定网格?
dt.DefaultView.Sort = e.SortExpression + " ASC";
gv.DataSource = dt;
gv.DataBind();