private void PopulateJobs() { Facade.IJob facJob = new Facade.Job(); DataSet ds = facJob.GetGoodsReturnJobsMissingReturnReceipts(); DataView dv = new DataView(ds.Tables[0]); string sortExpression = SortCriteria + " " + SortDirection; dv.Sort = sortExpression.Trim(); // Stop the page throwing an error if we're on the last page (with on entry) that is then removed on update. if (dv.Table.Rows.Count % dgJobs.PageSize == 0 && dv.Table.Rows.Count / dgJobs.PageSize == dgJobs.CurrentPageIndex && dgJobs.CurrentPageIndex > 1) { dgJobs.CurrentPageIndex--; } dgJobs.DataSource = dv; dgJobs.DataBind(); }