I am looping on list which has 19 records. I want to get records in 4 pages. First page will have 5 records, second will have 5 , Third will have 5 and fourth will have 4 records.
So i am looping as below
for (int i = 0; i < totalColumnToShow; i++)
{
var page = i + 1;
var skip = rowsPerColumn[i] * (page - 1);
PagedList =GroupedLinksCategory.Select(y => new copiedList { Title = y.Title, ID = y.ID, Name= y.Name }).Skip(skip).Take(rowsPerColumn[i]).ToList();
foreach (var row in PagedList)
{
if (row.Name== "Test")
{
//my Logic
}
else
{
//my Logic
}
}
}
variable rowsPerColumn is array holding 4 records like
rowsPerColumn[0] = 5
rowsPerColumn[1]= 5
rowsPerColumn[2] = 5
rowsPerColumn[3]= 4
On last page i am getting 2 records from page 3. What is wrong With my Logic?