views:

1299

answers:

3

I have custom some controls residing in SharepPoint webparts. I use a GridView control to take advantage of the built-in paging and column sort. The GridView gets databound from a method that iterates through an SPlist (with a foreach loop) to build a DataTable. This looping through the list is required to apply logic to process the list prior to display in the grid.

As the list get bigger, the page takes longer (forever) to load. Even though the paging permits the GridView to display only 12 rows of data, I believe the foreach loop is processing the entire list.

I've done server-side paging in .Net with both SQL and nHibernate. It should be possible to do this in SharePoint, right?. I am looking for some guidence, sample code, or any type of direction. Even a definitive "you're an idiot" would help.

Anyone done this before? Or, does anyone have an alternative databind scheam that they could suggest?

Thanks.

+2  A: 

If its possible to get the data using an SPQuery you can use the RowLimit and ListItemCollectionPosition properties.

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.splistitemcollectionposition.aspx

http://www.zimbio.com/SQL/articles/625/Paging+SPList+Sharepoint

JMD
A: 

Paging under SharePoint is fundamentally the same as in ASP.NET and if there is a speed difference I would attribute it to your SharePoint datasource, rather than just the fact that the gridview is running in SharePoint.

Are you databinding more than you need to?

You could possibly cache your data in the Page.Cache object and destroy the cache copy whenever something like a delete or update dirties the data.

strongopinions
A: 

u r stupid , u even dont know dis much

intelligent