我无法使我的gridview点击标题能够进行排序

Cur*_*tis 0 html css asp.net sorting gridview

我有一个gridview,我根据对db的​​查询填充.我正在尝试在gridview上添加排序,但我无法使我的列标题可点击.我允许排序设置为true,我有我的OnSorting事件集.我的专栏有几种不同的类型.我知道我的代码背后需要的代码,但由于某种原因我无法点击标题.任何有关我缺少的帮助将不胜感激.

<asp:GridView ID="Grid1" runat="server"  
        AutoGenerateColumns="False" 
        OnSelectedIndexChanging="Selected_Row_Changing"
        DataKeyNames="ApplicationId"
        AllowPaging="True"
        OnPageIndexChanging="Grid1_PageIndexChanging"
        AllowSorting="True"
        OnSorting="Grid1_Sorting" 
        OnRowCreated="OnRowCreated"
        OnRowCommand="Grid1_RowCommand"
        OnRowDataBound="Grid1_RowDataBound">

        <Columns>
            <asp:templatefield ...>
                <itemtemplate>
                    <asp:linkbutton .../>
                </itemtemplate>
            </asp:templatefield>

            <asp:BoundField ... />

            <asp:HyperLinkField ... />

            <asp:ButtonField ...  />

        </Columns>
    </asp:GridView>
Run Code Online (Sandbox Code Playgroud)

Tim*_*ter 5

你没有设置SortExpression,对吗?

例如:

<asp:boundfield datafield="CompanyName"
     headertext="CompanyName"
     headerstyle-wrap="false"
     sortexpression="CompanyName"/>
Run Code Online (Sandbox Code Playgroud)