SPGridView paging controls not displaying

SPGridView paging controls not displaying

 

I’ve been meaning to blog this for a while so here goes. Recently I was working on a web part which contained an SPGridView. The SPGridView had been setup to allow paging but when I deployed the web part the paging controls would not display.

Eventually after some playing around I found out you need to set the PagerTemplate to null (if you are not using a custom one) after you have added the grid to the controls collection. If you set the PagerTemplate before adding the grid to the controls collection then the paging controls will not display.

[code lang="csharp"]myGrid.PagerSettings.Mode = PagerButtons.NumericFirstLast;
myGrid.PageIndexChanging += new GridViewPageEventHandler(claimsGrid_PageIndexChanging);
this.Controls.Add(claimsGrid);
claimsGrid.PagerTemplate = null; [/code]

 

Hope this helps Smile

2 thoughts on “SPGridView paging controls not displaying

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 class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">