private void SetPagination(int results) { int totalItems = results; TotalResults.Text = results + " results found"; int resultsPerPage = int.Parse(Request.QueryString["next"]); int pages = 0; if (totalItems % resultsPerPage == 0) { pages = totalItems / resultsPerPage; } else { pages = (totalItems / resultsPerPage) + 1; } List <Paginator> list = new List <Paginator>(); for (int i = 1, j = 0; i <= pages; i++, j += resultsPerPage) { list.Add(new Paginator { OrderId = i, Url = SetOffset(j) }); } Pagination.DataSource = list; Pagination.DataBind(); }