我的以下代码段不允许在DataGrid上进行排序:
<asp:DataGrid ID="tubewell" runat="server" AllowSorting="True"
AutoGenerateColumns="False" OnSortCommand="sortColumn"
>
<Columns>
<asp:BoundColumn DataField="tubeWell_ID" DataFormatString="#{0:c}"
HeaderText="Tubewell </br> ID"></asp:BoundColumn>
<asp:BoundColumn DataField="status" HeaderText="Status" Visible="False">
</asp:BoundColumn>
</Columns></asp:DataGrid>
以下内容允许:
<asp:DataGrid ID="tubewell" runat="server" AllowSorting="True"
AutoGenerateColumns="True" OnSortCommand="sortColumn"
>
</asp:DataGrid>
答案 0 :(得分:3)
当你有AutoGenerateColumns =“false”时,你需要手动将SortExpression设置为列(SortExpression =“myDataFieldInTheDb”)