Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SharePoint > SharePoint Development
SharePoint Development Programming and development for SharePoint Portal Server and Windows SharePoint Services
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SharePoint Development section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old December 20th, 2007, 06:03 AM
Registered User
Join Date: Dec 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to arunduttgp
Default Paging and Filtering with SPGridView

Hi Everybody,
I am creating a webpart to display data from SharePoint lists. I am using SPGridView for this. First time I am using SPGridView. I have to accomplish the following goals with my SPGridView.
  • Paging
  • Filtering
I could do all my jobs fine with a normal GridView but when I started using a SPGridView trouble started.
I reallly want to enable filtering but I really don't know how can implement it with the SPGridView.
Also I have another weired problem. The SPGridView is not showing the paging buttons. But it is accepting the PageSize property, only buttons are not visible.
I really dont know why this is happening.

Here is the code I am trying out.
protected override void CreateChildControls()
oGrid = new SPGridView();
oDS = new SPDataSource();
oGrid.AllowPaging = true;
oGrid.PageSize = 3;
oGrid.EnableViewState = true;
oGrid.PagerTemplate = null;
oGrid.TemplateControl = null;
oGrid.AutoGenerateColumns = false;
oGrid.PageIndexChanging += new GridViewPageEventHandler(oGrid_PageIndexChanging);
oDS.List = SPContext.Current.Web.Lists["Contacts"];
oGrid.AutoGenerateColumns = false;
BoundField colTitle = new BoundField();
colTitle.DataField = "Last Name";
colTitle.HeaderText = "Last Name";

oGrid.DataSource = oDS;


void oGrid_PageIndexChanging(object sender, GridViewPageEventArgs e)


oGrid.PageIndex = e.NewPageIndex;
Please help me.

Old December 1st, 2008, 09:36 PM
Registered User
Join Date: Dec 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts


I got stuck with same problem..

here is the answer.

Set the pagertemplate to null after you grid has been added to control collection.

            grid.PagerTemplate = null;

hope this helps!

Similar Threads
Thread Thread Starter Forum Replies Last Post
SPGridView kgaughan SharePoint Development 1 April 15th, 2009 06:14 PM
How to use OR during filtering..... raaj81 Reporting Services 0 July 30th, 2008 05:34 AM
DB recordset paging using ajax paging? kumiko Classic ASP Basics 0 May 26th, 2008 10:23 AM
How to edit/delete list items through SPGridView meera SharePoint Development 0 December 7th, 2007 11:32 AM
Objectdatasource, Custom Paging, and Filtering crimsondr ASP.NET 2.0 Professional 0 December 23rd, 2005 12:56 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.