簡體   English   中英

在asp:GridView列頂部沒有用於排序的Linkbutton

[英]No Linkbutton for sorting at top of asp:GridView columns

根據MSDN上的GridView文檔,在ASP.NET GridView控件上設置AllowPaging = true會自動在每一列的頂部創建一個LinkBut​​ton控件,但是我只是在這段非常簡單的代碼上獲得了靜態文本。 任何想法都將不勝感激!

<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>

因為BoundField控件上沒有SortExpression屬性,所以您應該將其更改為:

<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>

現在,您將在列標題中看到鏈接按鈕。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM