Force GridView to display PagerTemplate

When writing custom paging and presenting the data in a GridView, you will need to force the PagerTemplate to display. One method of doing this is by using the GridViews OnPreRender event to force it to happen.

[csharp]
protected void SearchResults_PreRender(object sender, EventArgs e)
{
GridViewRow pagerRow = SearchResults.BottomPagerRow;

if (pagerRow != null && pagerRow.Visible == false)
pagerRow.Visible = true;
}
[/csharp]

Advertisements