It's recommended that you enable Paging on the LLBLGenProDataSource.
In this case LLBLGenProDataSource, will only fetch entities which belong to the requested Page. (Page number).
When you are using LivePersistence (= true), everything is done for you, the PageNumber & PageSize is passed from the Grid to the LLBLGenProDataSource automatically. And the Number of Pages is calculated by the LLBLGenProDataSource and then passed to the Grid.
But when you are not using LivePersistence (= false):
1- you should pass the requested PageNumber & PageSize to the Method fetching the entities. (in the Perform_Select event).
And these are passed to the Perform_Select in the eventArgument parameter.
(e.PageNumber, e. PageSize).
protected void Categories_DS_PerformSelect(object sender, PerformSelectEventArgs e)
{
e.ContainedCollection.GetMulti(e.Filter, e.MaxNumberOfItemsToReturn , new SortExpression(CategoryFields.CategoryName | SortOperator.Ascending), e.Relations, e.PageNumber, e.PageSize);
}
2- You should count the number of entities (used with the page size to determine the number of pages.)
To do this you should call GetDbCount(), to count all numbers in the database, instead of getting the count of the fetched entityCollection, which in this case will only contain entities for one page.
protected void Categories_DS_PerformGetDbCount(object sender, PerformGetDbCountEventArgs e)
{
// When enabling paging in the datasource,
// Don't get the entities count from the already fetched collection.
// these would be only those belonging to the first page.
//e.DbCount = e.ContainedCollection.Count;
// Get the count of all entities in the database
e.DbCount = e.ContainedCollection.GetDbCount();
}
Otherwise if you don't enable paging in the datasource and you just enabled paging in the Grid control, then LLBLGenProDataSource will fetch all entities in the database and the paging will be done in the Grid.
So you don't need to pass the PageNumber nor the Page Size to the fetching method.
And you may get all entities count from the Fetched entityCollectiuon count.
Of-course this is not recommended as then you will fetch all entities in the database each time you request to view one page of them.