var skip = selectedPage*pageSize;
var take = Math.Min(result.DataSourceCount - skip, pageSize);
List<SENTINEL_OPERATION> results = sentinelOperationManager.SearchSentinelOperations(sid).Skip(skip).Take(take).ToList();
My last page always gets empty. Im using a PageDataSource to get the pagesize and sending the clicked page using jquery ajax get. Did i miss something? Thanks
I bet, that
selectedPagestarts from 1 in your code and this is causing erros. Then you getskip == pageSizewhen on first page, and you go “out of range” on last page, but you are skipping the “real” first page.If
selectedPagestarts from1, then change this formula to:Also – there is no need to manually calculate
takevalue. You can just passpageSizeand it will always work. If your data source will not contain enough elements, nothing wrong will happen, just elements that are available will be returned.