With everything else being equal, a BoundField column in an asp:GridView is sortable, but a TemplateField column is not. Why is that?
<asp:LinqDataSource ID="someDataSource" runat="server"
ContextTypeName="someDataContext" TableName="someTable"
OnSelecting="someSelectingHandler" />
<asp:GridView ID="somGrid" runat="server"
AllowPaging="true" AllowSorting="true"
EnableSortingAndPagingCallbacks="true" PageSize="15"
DataSourceID="someDataSource" EnableViewState="true"
EmptyDataText="No orders matched your criteria">
<Columns>
<!-- resulting column is sortable: -->
<asp:BoundField HeaderText="Order #" HtmlEncode="false"
DataField="order_number" SortExpression="order_number">
</asp:BoundField>
<!-- resulting column is not sortable: -->
<asp:TemplateField SortExpression="order_number">
<HeaderTemplate>Order #</HeaderTemplate>
<ItemTemplate><%# DataBinder.Eval(Container.DataItem,
"order_number")%></ItemTemplate>
</asp:TemplateField>
Clicking on the BoundField header results in a post-back and my Selecting event handler is called. It just returns an IQueryable and itself does not handle sorting. The documentation merely says that the "underlying data source must support sorting" in order for the GridView to be sortable. Apparently the LinqDataSource supports sorting, or else the BoundField would not be sortable. Or am I missing something?