public void BindGrid() { int page = 0; if (Request.QueryString["page"] != null) { try { page = int.Parse(Request.QueryString["page"]); } catch { page = 0; } } List <Article> ls = ArticleHelper.GetMyArticles(((User)Session["User"]).UserID); Repeater1.DataSource = ls.Skip(20 * page).Take(20); //Repeater1.DataSource = ArticleHelper.GetMyArticles(((User)Session["User"]).UserID); Repeater1.DataBind(); TotalPage.Text = Math.Ceiling(ls.Count / 20.0).ToString(); currentPage.Text = (page + 1).ToString(); Prev.NavigateUrl = "MyArticles.aspx?page=" + (page - 1).ToString(); Next.NavigateUrl = "MyArticles.aspx?page=" + (page + 1).ToString(); Last.NavigateUrl = "MyArticles.aspx?page=" + ls.Count / 20; if (page == 0) { First.Enabled = false; Prev.Enabled = false; } if (page == (int)Math.Ceiling(ls.Count / 20.0) - 1) { Next.Enabled = false; Last.Enabled = false; } }