//Bind data
this.IncomeGridView.DataSource = incomeData;
//If incomeData is not empty then Taking the value of the Id field of the first and the last row in data page
if (incomeData.Count() > 0)
{
this.incomePaging_IdAtTheEndOfCurrentPage = incomeData.ToList()[incomeData.Count() - 1].Id;
**this.incomePaging_IdAtTheStartOfCurrentPage = incomeData.ToList()[0].Id;**
}
I take a page data but at the bold line the incomeData object contains data of the next data page automatically. Why did the Entity Framework do like that?
If you have all items in the GridView, and you use the built-in paging over all the items (ie if incomeData contains all items, and the gridview shows a section of that), then you need to look at the first visible item of IncomeGridView.
The best solution is using the PageIndex and PageSize columns: