SPGridView Paging

Scenario:
Enable Paging option on a SPGridView.

Implementation:

// oSPGridView is your Grid Instance
//Under CreateChildControls()

oSPGridView.PageSize = nPagerSize;
oSPGridView.AllowPaging = true;
oSPGridView.PageIndexChanging += new GridViewPageEventHandler(oSPGridView_PageIndexChanging);

oSPGridView.PagerTemplate = null;

// Under PageIndexChanging Event
void oSPGridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
oSPGridView.PageIndex = e.NewPageIndex;
oSPGridView.DataBind();
}

Comments