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

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();
                            else
                                dt.Merge(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 ?

share|improve this question

2 Answers 2

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.

share|improve this answer

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.