Hello everyone,
I found this article "https://www.codeproject.com/Articles/125541/Effective-Paging-with-GridView-Control-in-ASP-NET" which explains how to implement an effective sorting. Unfortunately, the author is using an ObjectDataSource to display the data to the grid view while I am displaying the data from the code behind. Can someone help me to implement his idea from the code behind? Below is the gridview and ObjectDataSource mark-up
- <div>
- <asp:GridView ID="gvProfile" DataSourceID="profileDataSource" runat="server" AutoGenerateColumns="false"
- AllowPaging="true" AllowSorting="true" PageSize="5" HeaderStyle-Font-Names="Verdana"
- Font-Size="Small" HeaderStyle-HorizontalAlign="Left" HeaderStyle-Font-Underline="false"
- Width="55%" HeaderStyle-BackColor="BurlyWood" HeaderStyle-ForeColor="Navy">
- <AlternatingRowStyle BackColor="Aquamarine" />
- <Columns>
- <asp:BoundField DataField="ProfileId" HeaderText="Profile Id" SortExpression="ProfileId"
- ItemStyle-Width="6%" />
- <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" ItemStyle-Width="13%" />
- <asp:BoundField DataField="Address" HeaderText="Address" SortExpression="Address"
- ItemStyle-Width="18%" />
- <asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" ItemStyle-Width="8%" />
- <asp:BoundField DataField="Mobile" HeaderText="Mobile" SortExpression="Mobile" ItemStyle-Width="9%" />
- <asp:BoundField DataField="IsActive" HeaderText="Status" SortExpression="IsActive" ItemStyle-Width="4%" />
- </Columns>
- </asp:GridView>
- </div>
- </center>
- <asp:ObjectDataSource ID="profileDataSource" runat="server" SelectMethod="GetProfileData" EnablePaging="true" MaximumRowsParameterName="pageSize"
- StartRowIndexParameterName="startRowIndex" TypeName="VTS.Web.UI.ProfileDataSource" SelectCountMethod="TotalRowCount"
- SortParameterName="sortExpression">
- <SelectParameters>
- <asp:Parameter Name="startRowIndex" Type="Int32" />
- <asp:Parameter Name="pageSize" Type="Int32"/>
- <asp:Parameter Name="sortExpression" Type="String" />
- </SelectParameters>
- </asp:ObjectDataSource>
Thank you in advance.