Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a requirement of filtering the data from the SPList (ex:20000 SPListItems) and I bind it to the radgrid. I want to get first 200 and next 200 of every page click in the radgrid.

This is my code:

DataTable dt=new DataTable();
SPQuery query = new SPQuery();
query.ViewAttributes = "Scope=\"SiteCollection\"";
query.Query = "<Where><Eq><FieldRef Name='Title'><Value Type='Text'>s</Value></Eq></Where>";
query.ViewFields = "<FieldRef Name='Title'>";
query.ViewFieldsOnly = true;
query.QueryThrottleMode = SPQueryThrottleOption.Strict;
splist.EnableThrottling = false;
query.RowLimit = 2000;
 do
                        {
                            SPListItemCollection myItems = splist.GetItems(query);
                            if (dt == null || dt.Rows.Count <= 0)
                                dt = myItems.GetDataTable();
                            else
                                dt.Merge(myItems.GetDataTable());
                            query.ListItemCollectionPosition = myItems.ListItemCollectionPosition;
                        }
                        while (query.ListItemCollectionPosition != null);

How do I paginate the results?

share|improve this question
    
This question is borderline off topic per the FAQ we do not accept questions about commercial, third-party products. You may want to ask your question on Telerik's support site: telerik.com/support.aspx –  Kit Menke Nov 27 '11 at 19:13
add comment

1 Answer 1

1) You don't need the ViewAttributes node in your example, as you're targeting a single list.

2) Your pages will be 2000 items long with your current RowLimit attribute

3) You have the throttle mode set to Strict when infact you disable throttling the line after - try it without these settings omitted and logged in as Admin first.

4) Have you tried a simplified version without the DataTable first, from the MSDN page on the ListItemCollectionPosition property? http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spquery.listitemcollectionposition.aspx

share|improve this answer
    
Hi james, Thanks for your reply, clearly i explain my scenario, kindly give the solution for this. 1. i have 20000 records in my sharepoint custom list like List1, List2,List3.......List20000. 2. i want to get the list items using SPList.GetItems(SPQuery), my list items result count is 10000. 3. in this 10000 items i don't want to show all 10000 items, i need to show only first 200 items, and next 200 items and next 200 items, is it possible, kindly give the solution fo this –  Rasu Nov 28 '11 at 7:05
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.