Mike
Mike

Reputation: 417

No Linkbutton for sorting at top of asp:GridView columns

According to the GridView documentation on MSDN, setting AllowPaging = true on an ASP.NET GridView control automatically creates a LinkButton control at the top of every column, but I am just getting static text on this very simple bit of code. Any ideas are greatly appreciated!

<asp:GridView ID="grdAttachments" runat="server" AllowPaging="true" AllowSorting="true" AutoGenerateColumns="false" DataKeyNames="pKey"
    OnSorting="grdAttachments_Sorting" >
    <Columns>
        <asp:BoundField HeaderText="Date" DataField="AttchDate" />
        <asp:BoundField HeaderText="File Name" DataField="AttchPath" />
        <asp:BoundField HeaderText="Attached By" DataField="AttchBy" />
    </Columns>
</asp:GridView>

Upvotes: 0

Views: 124

Answers (1)

Ali
Ali

Reputation: 2592

Because there is no SortExpression property on your BoundField controls.. you should change it to:

<Columns>
    <asp:BoundField HeaderText="Date" DataField="AttchDate" SortExpression="AttchDate" />
    <asp:BoundField HeaderText="File Name" DataField="AttchPath" SortExpression="AttchPath" />
    <asp:BoundField HeaderText="Attached By" DataField="AttchBy" SortExpression="AttchBy" />
</Columns>

now you will see the link buttons in the column header.

Upvotes: 1

Related Questions