PagerRow not showing in SPGridView when setting AllowPaging=true

When you enable paging in an SPGridView, the PagerRow doesn’t show up by default. To work around this, you have to set the PagerTemplate to ‘null’ AFTER adding the control to the controls collection but BEFORE calling DataBind().

e.g.

protected override void CreateChildControls() {
SPGridView grid = new SPGridView;
grid.AllowPaging=true;
this.Controls.Add(grid);
//set PagerTemplate to null
grid.PagerTemplate = null;
grid.PageIndexChanging +=
new GridViewPageEventHandler(grid_PageIndexChanging);
grid.DataBind();
}

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>