Dynamically I am adding RadGrid to the page. I need to retrieve list item from the SharePoint list. Say I have 10000 items in the list using SPQuery, I will get filtered records as 2000 items. Here is the code for retrieving items from the list

using (SPSite site = new SPSite(siteUrl.Trim()))
                        using (SPWeb web = openWeb(siteUrl.Trim()))
                            if (!web.Exists)
                                return dt;
                            SPList splist = getList(web, new Guid(listId));
                            if (splist == null)
                                return dt;

                            SPQuery query = new SPQuery();
                            if (!string.IsNullOrEmpty(scope))
                                query.ViewAttributes = "Scope=\"" + scope + "\"";
                            query.Query = filterValue;
                            if (!string.IsNullOrEmpty(viewFields))
                                query.ViewFields = viewFields;
                                query.ViewFieldsOnly = true;
                            query.QueryThrottleMode = SPQueryThrottleOption.Strict;
                            //splist.EnableThrottling = false;
                            query.RowLimit = Convert.ToUInt32(rowLimit);
                            SPListItemCollection myItems = splist.GetItems(query);
                            itemcollection = myItems;
                            if (dt == null || dt.Rows.Count <= 0)
                                dt = myItems.GetDataTable();
                return dt;

The above code returns the datatable which has 2000 records that will be bound to the RadGrid. I need to get the every 20 records from the table based on the item ID column. I had achieved this using DataTable.select top 20 rows(based on ItemID column) for the first page in the RadGrid but how can I retrieve next 20 items(such as 21-40,41-60.....) to show for the second page in the RadGrid. How to retrieve item from the list based on the itemID ?

Could anyone provide a solution for this issue ?


2 Answers 2


Check this to see if it helps - http://blogs.msdn.com/b/powlo/archive/2007/03/23/adding-paging-to-spgridview-when-using-custom-data-sources.aspx


1) This is ok but uou should use LINQ Query

2) There are things like SKIP and TAKE in LINQ

3) If I have loaded 20 records in first time and in the second time I can skip the first 20 and I can take the second 20 records or items.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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