There are some things I don’t like about gridviews, but one of the things I do like is that all I’ve ever needed to do to add paging and sorting is use the “AllowPaging” and “AllowSorting” attributes. Done.
However, for the first time I’m getting misbehavior. Everything on the page was working fine before I started. All I changed was adding AllowPaging (and PageSize) and Allow Sorting. The paging is working fine, but the column headings did not change and don’t sort. I removed the allowsorting attribute rebuilt the app, then added it back and rebuilt again. Nothing changes at any point. It’s like it’s not recognizing that the sorting attribute is there. Any ideas?
<asp:GridView ID="gvCampaignCookies" runat="server"
DataSourceID="LinqDataSourceList" AllowPaging="true" PageSize="20"
AllowSorting="true" CssClass="datagrid" GridLines="None"
AutoGenerateColumns="false"
OnSelectedIndexChanged="gvCampaignCookies_SelectedIndexChanged"
DataKeyNames="id">
<Columns>
<asp:BoundField DataField="id" HeaderText="id" ReadOnly="true" />
<asp:BoundField DataField="myid" HeaderText="myid" ReadOnly="true" />
<asp:BoundField DataField="domain" HeaderText="domain" ReadOnly="true" />
<asp:BoundField DataField="cid" HeaderText="cid" ReadOnly="true" />
<asp:BoundField DataField="leadsource" HeaderText="leadsource" ReadOnly="true" />
<asp:BoundField DataField="leadsourcedetail" HeaderText="leadsourcedetail" ReadOnly="true" />
<asp:BoundField DataField="aid" HeaderText="aid" ReadOnly="true" />
<asp:BoundField DataField="productid" HeaderText="productid" ReadOnly="true" />
<asp:BoundField DataField="url" HeaderText="url" ReadOnly="true" />
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="btnViewDetails" runat="server" Text="Edit" CommandName="Select" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="btnDelete" runat="server" Text="Delete" CommandName="Delete" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>