Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/287.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 带绑定字段的Gridview排序_C#_Asp.net_.net - Fatal编程技术网

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();