Try following code.
//For paging a Gridview manually we have to handle the Gridview’s PageIndexChanged Event.
//In the event we need to change the PageIndex of Gridview to the page that user has clicked and again bind the Gridview.
protected void gvPaging_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
gvPaging.PageIndex = e.NewPageIndex;
gvPaging.DataBind();
}
//This is all you need to do to make manual paging in the Gridview.
//For manually sorting in Gridview we need to handle the Sorting event of Gridview. Here is the code to do it.
protected void gvSorting_Sorting(object sender, GridViewSortEventArgs e)
{
DataTable dtSortTable = gvSorting.DataSource as DataTable;
if (dtSortTable != null)
{
DataView dvSortedView = new DataView(dtSortTable);
dvSortedView.Sort = e.SortExpression + " " + getSortDirectionString(e.SortDirection);
gvSorting.DataSource = dvSortedView;
gvSorting.DataBind();
}
}
private string getSortDirectionString(SortDirection sortDireciton)
{
string newSortDirection = String.Empty;
if(sortDirection== SortDirection.Ascending)
{
newSortDirection = "ASC";
}
else
{
newSortDirection = "DESC";
}
return newSortDirection
}
HTH
Jinal Desai - LIVE Experience is mother of sage....