I am using PagedList.Mvc in my project and its working absolutely fine.But the problem is after installing it serialno is not autoincremented.
For example if i've 20 records in the db and showing only 10 records in the page listed from 1 to 10,on selecting second page instead of showing serialno from 11 to 20,its still showing serialno as 1 to 10 .
The code is given below
<tbody>
@foreach (var item in Model.Select((x, i) => new { Data = x, Index = i }))
{
<tr>
<td>@(item.Index+1)</td> `SerialNo is displayed here`
<td>@Html.DisplayFor(modelItem=>item.Data.SITENAME)</td>
<td>@Html.DisplayFor(modelItem=>item.Data.REMARKS)</td>
</tr>
</tbody>
How can i retain the value of last record and increment onselecting the second page ??
Assuming that your model here is PagedList<T>
, then you would need to calculate the current number using:
@(item.Index + ((Model.PageNumber - 1) * Model.PageSize) + 1)