private string Generate_Pagination_Links(int TotalPages) { StringBuilder str = new StringBuilder(); int firstbound = 0; int lastbound = 0; string ToolTip = ""; ArrayList arr = Pagination_Process.Return_Pagination_Link_v2(TotalPages, this.PageNumber); if (arr.Count > 0) { int i = 0; for (i = 0; i <= arr.Count - 1; i++) { firstbound = ((int.Parse(arr[i].ToString()) - 1) * this.PageSize) + 1; lastbound = firstbound + this.PageSize - 1; if (lastbound > this.TotalRecords) { lastbound = this.TotalRecords; } ToolTip = showing + " " + firstbound + " - " + lastbound + " " + records + " " + Resources.vsk.of + " " + this.TotalRecords + " " + records; string _css = ""; if (arr[i].ToString() == this.PageNumber.ToString()) { _css = " class=\"active\""; } str.Append("<li" + _css + "><a id=\"pg_" + arr[i].ToString() + "\" href=\"#\" class=\"pagination-css\" title=\"" + ToolTip + "\">" + arr[i].ToString() + "</a></li>\n"); } } return(str.ToString()); }
// Pagination Script version 3.0, support VSK 5.3 listing (SQL SERVER 2005, MySQL compatible) // Compatible with both MySQL / SQL SERVER. // Support Advance Pagination public static void Process_Pagination_v3(Repeater _rept, HyperLink _prev, HyperLink _next, int _size, int _pagenumber, int _totalrecords) { // MySQL Compatible int total_pages = (int)Math.Ceiling((double)_totalrecords / _size); if (total_pages > 1) { // Previous Link Scripting if (_pagenumber > 1) { _prev.Visible = true; int firstbound = (((_pagenumber - 1) - 1) * _size) + 1; if (firstbound < 0) { firstbound = 1; } int lastbound = firstbound + _size - 1; _prev.ToolTip = "Showing " + firstbound + " - " + lastbound + " records of " + _totalrecords + " records"; } else { _prev.Visible = false; } // Next Link Scripting if (_pagenumber < total_pages) { _next.Visible = true; int firstbound = (((_pagenumber + 1) - 1) * _size) + 1; int lastbound = firstbound + _size - 1; if (lastbound > _totalrecords) { lastbound = _totalrecords; } _next.ToolTip = "Showing " + firstbound + " - " + lastbound + " records of " + _totalrecords + " records"; } else { _next.Visible = false; } // main pagination links ArrayList arr = Pagination_Process.Return_Pagination_Link_v2(total_pages, _pagenumber); _rept.Visible = true; _rept.DataSource = arr; _rept.DataBind(); } else { _rept.Visible = false; _next.Visible = false; _prev.Visible = false; } }
private string Generate_Pagination_Links(int TotalPages, string _rooturl) { StringBuilder str = new StringBuilder(); int firstbound = 0; int lastbound = 0; string ToolTip = ""; ArrayList arr = Pagination_Process.Return_Pagination_Link_v2(TotalPages, this.PageNumber); if (arr.Count > 0) { int i = 0; string LinkURL = ""; string Item = ""; for (i = 0; i <= arr.Count - 1; i++) { Item = arr[i].ToString(); firstbound = ((int.Parse(Item) - 1) * this.PageSize) + 1; lastbound = firstbound + this.PageSize - 1; if (lastbound > this.TotalRecords) lastbound = this.TotalRecords; ToolTip = showing + " " + firstbound + " - " + lastbound + " " + records + " " + Resources.vsk.of + " " + this.TotalRecords + " " + records; // url settings // normal search if (Item == "1") { if (this.isFilter) // videos/MostViewed/ThisWeek.aspx LinkURL = Config.GetUrl() + "" + this.Filter_Default_Url; else // videos/MostViewed.aspx LinkURL = Config.GetUrl() + "" + this.Default_Url; } else { if (this.isFilter) // videos/MostViewed/232/ThisWeek.aspx LinkURL = Config.GetUrl() + "" + UtilityBLL.Add_PageNumber(this.Filter_Pagination_Url, Item); else // videos/232/MostViewed.aspx LinkURL = Config.GetUrl() + "" + UtilityBLL.Add_PageNumber(this.Pagination_Url, Item); } string _css = ""; if (arr[i].ToString() == this.PageNumber.ToString()) _css = "class=\"active\""; str.Append("<li " + _css + "><a href=\"" + LinkURL + "\" title=\"" + ToolTip + "\">" + arr[i].ToString() + "</a></li>\n"); } } return str.ToString(); }
// Process Pagination ver 2.0 // Compatible with Hyperlinks // Compatible with both MySQL / SQL SERVER. // Support Advance Pagination public static void Process_Pagination_v2(DataList _list, Repeater _rept, HyperLink _prev, HyperLink _next, int _size, int _pagenumber, IEnumerable _source, int _totalrecords) { if (Site_Settings.Pagination_Type == 1) { // MySQL Compatible int total_pages = (int)Math.Ceiling((double)_totalrecords / _size); if (total_pages > 1) { // Previous Link Scripting if (_pagenumber > 1) { _prev.Visible = true; int firstbound = (((_pagenumber - 1) - 1) * _size) + 1; if (firstbound < 0) { firstbound = 1; } int lastbound = firstbound + _size - 1; _prev.ToolTip = "Showing " + firstbound + " - " + lastbound + " records of " + _totalrecords + " records"; } else { _prev.Visible = false; } // Next Link Scripting if (_pagenumber < total_pages) { _next.Visible = true; int firstbound = (((_pagenumber + 1) - 1) * _size) + 1; int lastbound = firstbound + _size - 1; if (lastbound > _totalrecords) { lastbound = _totalrecords; } _next.ToolTip = "Showing " + firstbound + " - " + lastbound + " records of " + _totalrecords + " records"; } else { _next.Visible = false; } // main pagination links ArrayList arr = Pagination_Process.Return_Pagination_Link_v2(total_pages, _pagenumber); _rept.Visible = true; _rept.DataSource = arr; _rept.DataBind(); } else { _rept.Visible = false; _next.Visible = false; _prev.Visible = false; } _list.DataSource = _source; _list.DataBind(); } else { // SQL SERVER Compatible PagedDataSource objPds = new PagedDataSource(); objPds.DataSource = _source; objPds.AllowPaging = true; objPds.PageSize = _size; objPds.CurrentPageIndex = (_pagenumber - 1); if (!objPds.IsFirstPage) { _prev.Visible = true; int firstbound = (((_pagenumber - 1) - 1) * _size) + 1; if (firstbound < 0) { firstbound = 1; } int lastbound = firstbound + _size - 1; _prev.ToolTip = "Showing previous " + firstbound + " - " + lastbound + " records of " + _totalrecords + " records"; } else { _prev.Visible = false; } if (!objPds.IsLastPage) { int firstbound = (((_pagenumber + 1) - 1) * _size) + 1; int lastbound = firstbound + _size - 1; if (lastbound > _totalrecords) { lastbound = _totalrecords; } _next.ToolTip = "Showing next " + firstbound + " - " + lastbound + " records of " + _totalrecords + " records"; _next.Visible = true; } else { _next.Visible = false; } ArrayList arr = Pagination_Process.Return_Pagination_Link_v2(objPds.PageCount, _pagenumber); if (objPds.PageCount > 1) { _rept.Visible = true; _rept.DataSource = arr; _rept.DataBind(); } else { _rept.Visible = false; } _list.DataSource = objPds; _list.DataBind(); } }