Jacob_Zac
PageIndex is properly set, but in gridview first page is displayed and not the last.
Pager buttons show that the last page is selected which is not the case.
Try setting the PagelIndex on pageload event like below
protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { gridViewGuestEntries.PageIndex = Int32.MaxValue; //Your code to get the value //gridViewGuestEntries.DataSource = ; //gridViewGuestEntries.DataBind(); } }
You can check this link for more details : http://forums.asp.net/t/1293215.aspx?Display+last+page+of+a+Gridview+Programmatically