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 ?