i have a gridview that is being populated ok. Now i want to enable sorting. Ive done all the required code - namely enabling sorting on the markup and providing the event to call when a user sorts.
its the sort event that im lost with - i have tried a few implementations from Google but im not too sure. Essentially am i corect in saying that i need to provide new queries back to the server depending on what column the user wants to sort by and ASC or DESC also? if so it sounds like alot of more work....more queries.
thanks damo
Code Behind to Bind the grid
// Load the main homepage data to the grid
FAServices fServices = new FAServices(sConn);
FAAuditOverallStatusLatest fAuditOverallStatusLatest = new FAAuditOverallStatusLatest(sConn);
GridViewMain.DataSource = fAuditOverallStatusLatest.getAuditOverallStatusLatest();
GridViewMain.DataBind();
Code behind to sort
protected void GridViewMain_Sorting(object sender, GridViewSortEventArgs e)
{
// Switch statements required here along with Query for each column i have in the grid
}
Grid Markup
<asp:GridView ID="GridViewMain" OnRowDataBound="GridViewMainRowDataBound" OnPageIndexChanging="GridViewMain_PageIndexChanging"
runat="server" AllowPaging="True" PageSize="50" PagerSettings-Position="TopAndBottom"
CssClass="mGrid"
PagerStyle-CssClass="pgr"
AlternatingRowStyle-CssClass="alt data-row"
OnRowCreated="GridViewMain_RowCreated"
RowStyle-CssClass="data-row"
AllowSorting="True"
OnSorting="GridViewMain_Sorting"
>
</asp:GridView>