Description:
The TotalPages property currently uses Math.Floor to calculate the number of pages, which results in incorrect values when the total number of items is not perfectly divisible by ItemsPerPage.
Problem:
In the current implementation:
return (int)Math.Floor((double)Total / ItemsPerPage);
This will cause the result to round down, omitting the additional page required for the remaining items.
Example:
If Total = 275 and ItemsPerPage = 20:
- Expected
TotalPages = 14 (13 full pages + 1 partial)
- Actual
TotalPages = 13 (incorrect)
Proposed Fix:
Replace Math.Floor with Math.Ceiling to ensure partial pages are counted correctly:
This will correctly return 14 pages for the example above.
Description:
The
TotalPagesproperty currently usesMath.Floorto calculate the number of pages, which results in incorrect values when the total number of items is not perfectly divisible byItemsPerPage.Problem:
In the current implementation:
This will cause the result to round down, omitting the additional page required for the remaining items.
Example:
If
Total = 275andItemsPerPage = 20:TotalPages= 14 (13 full pages + 1 partial)TotalPages= 13 (incorrect)Proposed Fix:
Replace
Math.FloorwithMath.Ceilingto ensure partial pages are counted correctly:This will correctly return 14 pages for the example above.