For adding Paging
in asp.net gridview
you have to handle OnPageIndexChanging
event:
Markup:
<asp:GridView ID="gvInvoiceList"
DataSourceID="DSInvoiceMaster"
AutoGenerateColumns="false"
CssClass="table table-striped table-hover"
EnableSortingAndPagingCallbacks ="false"
AllowPaging="True"
AllowSorting="True"
PageSize="5"
OnRowCommand="gvPrograms_RowCommand"
OnPageIndexChanging="gvInvoiceList_PageIndexChanging"
runat="server">
Code behind:
protected void gvInvoiceList_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
gvInvoiceList.PageIndex = e.NewPageIndex;
gvInvoiceList.DataBind();
}
MSDN example on GridView.OnPageIndexChanging Event.
For Sorting
you have track OnSorting
event of gridview.
MSDN example reference on GridView.Sorting event.
Here is example reference.
UPDATE: you have not specified datasourceid
of gridview here. See updated markup.