protected void BindPagingControls() { if (_lastPageIndex > 0) { PagerPanel.Visible = (PagingLinksLocation == "BOTTOM" || PagingLinksLocation == "TOPANDBOTTOM"); PagerPanelTop.Visible = (PagingLinksLocation == "TOP" || PagingLinksLocation == "TOPANDBOTTOM"); float tempIndex = ((float)_currentPageIndex / 10) * 10; int currentPagerIndex = (int)tempIndex; int totalPages = currentPagerIndex + 1 + _pageSize; // ADD ONE BECAUSE IT IS A ZERO BASED INDEX if (totalPages > (_lastPageIndex + 1)) { totalPages = (_lastPageIndex + 1); } string baseUrl; if (_Category != null) { baseUrl = this.Page.ResolveUrl(_Category.NavigateUrl) + "?"; } else { baseUrl = this.Page.ResolveUrl(Request.Url.AbsolutePath) + "?"; } string s = Request.QueryString["s"]; if (!string.IsNullOrEmpty(s)) { baseUrl = baseUrl + "s=" + s + "&"; } string ps = Request.QueryString["ps"]; if (string.IsNullOrEmpty(ps)) { ps = _pageSize.ToString(); } if (!string.IsNullOrEmpty(ps)) { baseUrl = baseUrl + "ps=" + ps + "&"; } if (PagerPanel.Visible) { PagerControls.DataSource = AbleCommerce.Code.NavigationHelper.GetPaginationLinks(currentPagerIndex, totalPages, baseUrl); PagerControls.DataBind(); } if (PagerPanelTop.Visible) { PagerControlsTop.DataSource = AbleCommerce.Code.NavigationHelper.GetPaginationLinks(currentPagerIndex, totalPages, baseUrl); PagerControlsTop.DataBind(); } } else { PagerPanel.Visible = false; PagerPanelTop.Visible = false; } }
protected void BindPagingControls() { if (_lastPageIndex > 0) { PagerPanel.Visible = (PagingLinksLocation == "BOTTOM" || PagingLinksLocation == "TOPANDBOTTOM"); PagerPanelTop.Visible = (PagingLinksLocation == "TOP" || PagingLinksLocation == "TOPANDBOTTOM"); float tempIndex = ((float)_hiddenPageIndex / 10) * 10; int currentPagerIndex = (int)tempIndex; int totalPages = currentPagerIndex + 1 + _pageSize; // ADD ONE BECAUSE IT IS A ZERO BASED INDEX if (totalPages > (_lastPageIndex + 1)) { totalPages = (_lastPageIndex + 1); } string baseUrl; if (_category != null) { baseUrl = this.Page.ResolveUrl(_category.NavigateUrl) + "?"; } else if (this.CategoryId == 0) { baseUrl = this.Page.ResolveUrl(Request.Url.AbsolutePath) + "?"; } else { baseUrl = AbleCommerce.Code.NavigationHelper.GetStoreUrl(this.Page, "Search.aspx?"); } //if (!string.IsNullOrEmpty(_Keywords)) baseUrl += "k=" + Server.UrlEncode(_Keywords) + "&"; //if (_ManufacturerId != 0) baseUrl += "m=" + _ManufacturerId.ToString() + "&"; if (!String.IsNullOrEmpty(SortResults.SelectedValue)) { baseUrl += "s=" + SortResults.SelectedValue + "&"; } if (!string.IsNullOrEmpty(PageSizeOptions.SelectedValue)) { baseUrl += "ps=" + PageSizeOptions.SelectedValue + "&"; } if (PagerPanel.Visible) { PagerControls.DataSource = AbleCommerce.Code.NavigationHelper.GetPaginationLinks(currentPagerIndex, totalPages, baseUrl); PagerControls.DataBind(); } if (PagerPanelTop.Visible) { PagerControlsTop.DataSource = AbleCommerce.Code.NavigationHelper.GetPaginationLinks(currentPagerIndex, totalPages, baseUrl); PagerControlsTop.DataBind(); } } else { PagerPanel.Visible = false; PagerPanelTop.Visible = false; } }
protected void BindPagingControls() { Trace.Write(this.GetType().ToString(), "Begin BindPagingControls"); if (_lastPageIndex > 0) { PagerPanel.Visible = true; List <PagerLinkData> pagerLinkData = new List <PagerLinkData>(); float tempIndex = ((float)_hiddenPageIndex / 10) * 10; int currentPagerIndex = (int)tempIndex; int totalPages = currentPagerIndex + 1 + _pageSize; // ADD ONE BECAUSE IT IS A ZERO BASED INDEX if (totalPages > (_lastPageIndex + 1)) { totalPages = (_lastPageIndex + 1); } string baseurl = string.Empty; string[] segm = this.Page.Request.Url.Segments; foreach (string sg in segm) { baseurl += sg; } string navigateUrl = string.Empty; // ESCAPE THE & WITH & and SPACES with + TO AVOID HTML VALIDATION ISSUES baseurl += "?" + (String.IsNullOrEmpty(_keywords) ? "" : "k=" + _keywords + "&") + (_manufacturerId == 0 ? "" : "m=" + _manufacturerId.ToString() + "&") + (String.IsNullOrEmpty(SortResults.SelectedValue) ? "" : "s=" + SortResults.SelectedValue.Replace(" ", "+") + "&") + (_categoryId == 0 ? "" : "c=" + _categoryId.ToString() + "&"); if (!string.IsNullOrEmpty(PageSizeOptions.SelectedValue)) { baseurl += "ps=" + PageSizeOptions.SelectedValue + "&"; } if (!string.IsNullOrEmpty(_shopBy)) { baseurl += "shopby=" + _shopBy + "&"; } PagerControls.DataSource = AbleCommerce.Code.NavigationHelper.GetPaginationLinks(currentPagerIndex, totalPages, baseurl); PagerControls.DataBind(); } else { PagerPanel.Visible = false; } Trace.Write(this.GetType().ToString(), "End BindPagingControls"); }
}//end of lbBuyNow_Command() #region PagingControls protected void BindPagingControls() { if (_LastPageIndex > 0) { PagerPanel.Visible = true; PagerPanel2.Visible = true; List<PagerLinkData> pagerLinkData = new List<PagerLinkData>(); float tempIndex = ((float)_HiddenPageIndex / 10) * 10; int currentPagerIndex = (int)tempIndex ; int lastPagerIndex = currentPagerIndex + _PageSize; if (lastPagerIndex > _LastPageIndex) lastPagerIndex = _LastPageIndex; string baseUrl = "/Obituaries/flower.aspx?person=" + hfPersonId.Value + "&FHPID=" + hfFHPID.Value + "&oid=" + hfObituatyId.Value + "&cate=" + strCurrentCate + "&p="; string navigateUrl; //checks if there is any prev link to use if (currentPagerIndex > 0) { //checks if the currentOager is a least two away from the Pager Index //in order for the arrow to work if((currentPagerIndex - 1) > 0) pagerLinkData.Add(new PagerLinkData("Prev", (baseUrl + (currentPagerIndex - 1).ToString()), (currentPagerIndex - 1), true, "aPrevPage aPagingContorls aPage")); //goes around for the last up to the last 5 pages for display for(int intPagerIndex = (currentPagerIndex - 5); (currentPagerIndex - intPagerIndex) > 0; intPagerIndex++) { //checks if to make sure that it is more the zero in order to display it if(intPagerIndex >= 0) //adds the pager link pagerLinkData.Add(new PagerLinkData(((int)((intPagerIndex + 1))).ToString(), (baseUrl + intPagerIndex), intPagerIndex, (currentPagerIndex != _HiddenPageIndex), "aNumberPage aPage")); }//end of for loop }//end of if //goes around the next pages up to the 12 pages while (currentPagerIndex <= lastPagerIndex) { string linkText = ((int)(currentPagerIndex + 1)).ToString(); string strBasicCSSClass = "aNumberPage aPage";//holds the css class that will be used in all items //checks if this is the last number link if so then add a aNumberPageLastChild if(currentPagerIndex == lastPagerIndex) strBasicCSSClass += " aNumberPageLastChild"; if (currentPagerIndex != _HiddenPageIndex) { navigateUrl = baseUrl + currentPagerIndex.ToString(); //adds the pager link pagerLinkData.Add(new PagerLinkData(linkText, navigateUrl, currentPagerIndex, (currentPagerIndex != _HiddenPageIndex), strBasicCSSClass)); }//end of if else { navigateUrl = "javascript:void(0);"; //adds the pager link pagerLinkData.Add(new PagerLinkData(linkText, navigateUrl, currentPagerIndex, (currentPagerIndex != _HiddenPageIndex), "aCurrentPage " + strBasicCSSClass)); }//end of else currentPagerIndex++; }//end of while loop if (lastPagerIndex < _LastPageIndex) { navigateUrl = baseUrl + (lastPagerIndex + 1).ToString(); //adds the pager link pagerLinkData.Add(new PagerLinkData("Next", navigateUrl,lastPagerIndex + 1, true, "aNextPage aPagingContorls aPage")); }//end of if PagerControls.DataSource = pagerLinkData; PagerControls.DataBind(); PagerControls2.DataSource = pagerLinkData; PagerControls2.DataBind(); }//end of if else { PagerPanel.Visible = false; PagerPanel2.Visible = false; }//end of else }//end of BindPagingControls()
protected void Page_Load(object sender, System.EventArgs e) { string kwords = KeywordField.Text; if (string.IsNullOrEmpty(kwords)) { kwords = HiddenSearchKeywords.Value; } if (Page.IsPostBack && !string.IsNullOrEmpty(kwords)) { _keywords = StringHelper.StripHtml(kwords).Trim(); HiddenSearchKeywords.Value = _keywords; } else { _keywords = Server.UrlDecode(Request.QueryString["k"]); if (!string.IsNullOrEmpty(_keywords)) { _keywords = StringHelper.StripHtml(_keywords).Trim(); } } if (HasSearchCriteria()) { //has something to search ResultsPanel.Visible = true; NoSearchCriteriaPanel.Visible = false; ResultTermMessage.Visible = true; if (!Page.IsPostBack) { //initialize search sorting and paging criteria based on query string parameters HiddenPageIndex.Value = AlwaysConvert.ToInt(Request.QueryString["p"]).ToString(); string tempSort = Request.QueryString["s"]; if (!string.IsNullOrEmpty(tempSort)) { ListItem item = SortResults.Items.FindByValue(tempSort); if (item != null) { item.Selected = true; } } } //initialize paging vars _hiddenPageIndex = AlwaysConvert.ToInt(HiddenPageIndex.Value); _searchResultCount = ProductDataSource.AdvancedSearchCount(_keywords, _categoryId, _manufacturerId, true, true, true, 0, 0); _lastPageIndex = ((int)Math.Ceiling(((double)_searchResultCount / (double)_pageSize))) - 1; if (_hiddenPageIndex > _lastPageIndex) { _hiddenPageIndex = _lastPageIndex; } if (_pageSize == 0) { _pageSize = _searchResultCount; } //update the header search criteria message StringBuilder sb = new StringBuilder(); if (!string.IsNullOrEmpty(_keywords)) { sb.Append(string.Format(" for '{0}'", _keywords)); } Category category = CategoryDataSource.Load(_categoryId); if (category != null) { sb.Append(string.Format(" in '{0}'", category.Name)); } Manufacturer manufacturer = ManufacturerDataSource.Load(_manufacturerId); if (manufacturer != null) { sb.Append(string.Format(" in '{0}'", manufacturer.Name)); } ResultTermMessage.Text = string.Format(ResultTermMessage.Text, sb.ToString()); //bind search results int startIndex = (_hiddenPageIndex * _pageSize); if (startIndex < 0) { startIndex = 0; } var products = ProductDataSource.AdvancedSearch(_keywords, _categoryId, _manufacturerId, true, true, true, 0, 0, _pageSize, startIndex, SortResults.SelectedValue); // DELAYED QUERIES TO EAGER LOAD RELATED DATA FOR PERFORMANCE BOOST if (products.Count < 415) { List <int> ids = products.Select(p => p.Id).ToList <int>(); var futureQuery = NHibernateHelper.QueryOver <Product>() .AndRestrictionOn(p => p.Id).IsIn(ids) .Fetch(p => p.Specials).Eager .Future <Product>(); NHibernateHelper.QueryOver <Product>() .AndRestrictionOn(p => p.Id).IsIn(ids) .Fetch(p => p.ProductOptions).Eager .Future <Product>(); NHibernateHelper.QueryOver <Product>() .AndRestrictionOn(p => p.Id).IsIn(ids) .Fetch(p => p.ProductKitComponents).Eager .Future <Product>(); NHibernateHelper.QueryOver <Product>() .AndRestrictionOn(p => p.Id).IsIn(ids) .Fetch(p => p.ProductTemplates).Eager .Future <Product>(); futureQuery.ToList(); } ProductList.DataSource = products; ProductList.DataBind(); NoResultsPanel.Visible = _searchResultCount == 0; SortPanel.Visible = _searchResultCount > 1; //bind paging int totalPages; if (_pageSize <= 0) { totalPages = 1; } else { totalPages = (int)Math.Ceiling((double)_searchResultCount / _pageSize); } if (_lastPageIndex > 0) { PagerPanel.Visible = true; PagerPanelTop.Visible = true; List <PagerLinkData> pagerLinkData = GetPagingLinkData(totalPages); PagerControls.DataSource = pagerLinkData; PagerControls.DataBind(); PagerControlsTop.DataSource = pagerLinkData; PagerControlsTop.DataBind(); PagerMessageTop.Text = string.Format("Page {0} of {1}", (_hiddenPageIndex + 1), totalPages); PagerMessageBottom.Text = string.Format("Page {0} of {1}", (_hiddenPageIndex + 1), totalPages); } else { PagerPanel.Visible = false; PagerPanelTop.Visible = false; } } else { //no search criteria ResultsPanel.Visible = false; NoSearchCriteriaPanel.Visible = true; ResultTermMessage.Visible = false; } }
protected void Page_Load(object sender, System.EventArgs e) { Page.Title = string.IsNullOrEmpty(_category.Title) ? _category.Name : _category.Title; Caption.Text = _category.Name; if (!Page.IsPostBack) { //initialize search sorting and paging criteria based on query string parameters HiddenPageIndex.Value = AlwaysConvert.ToInt(Request.QueryString["p"]).ToString(); string tempSort = Request.QueryString["s"]; if (!string.IsNullOrEmpty(tempSort)) { ListItem item = SortResults.Items.OfType <ListItem>().SingleOrDefault(x => string.Compare(x.Value, tempSort, StringComparison.InvariantCultureIgnoreCase) == 0); if (item != null) { item.Selected = true; } } } //initialize paging vars _hiddenPageIndex = AlwaysConvert.ToInt(HiddenPageIndex.Value); _productCount = ProductDataSource.CountForCategory(_categoryId, false, true); _lastPageIndex = ((int)Math.Ceiling(((double)_productCount / (double)_pageSize))) - 1; if (_hiddenPageIndex > _lastPageIndex) { _hiddenPageIndex = _lastPageIndex; } if (_pageSize == 0) { _pageSize = _productCount; } //bind products ProductList.DataSource = ProductDataSource.LoadForCategory(true, _categoryId, false, true, SortResults.SelectedValue, _pageSize, (_hiddenPageIndex * _pageSize)); ProductList.DataBind(); ProductsPanel.Visible = _productCount > 0; if (_productCount == 0 && CategoryDataSource.CountForParent(_categoryId, true) == 0) { NoResultPanel.Visible = true; } //bind paging int totalPages; if (_pageSize <= 0) { totalPages = 1; } else { totalPages = (int)Math.Ceiling((double)_productCount / _pageSize); } if (_lastPageIndex > 0) { PagerPanel.Visible = true; PagerPanelTop.Visible = true; List <PagerLinkData> pagerLinkData = GetPagingLinkData(totalPages); PagerControls.DataSource = pagerLinkData; PagerControls.DataBind(); PagerControlsTop.DataSource = pagerLinkData; PagerControlsTop.DataBind(); PagerMessageTop.Text = string.Format("Page {0} of {1}", (_hiddenPageIndex + 1), totalPages); PagerMessageBottom.Text = string.Format("Page {0} of {1}", (_hiddenPageIndex + 1), totalPages); } else { PagerPanel.Visible = false; PagerPanelTop.Visible = false; } }
}//end of lbEndClearDate_Click() #region PagingControls protected void BindPagingControls() { if (_LastPageIndex > 0) { PagerPanel.Visible = true; List<PagerLinkData> pagerLinkData = new List<PagerLinkData>(); float tempIndex = ((float)_HiddenPageIndex / 10) * 10; int currentPagerIndex = (int)tempIndex ; int lastPagerIndex = currentPagerIndex + _PageSize; if (lastPagerIndex > _LastPageIndex) lastPagerIndex = _LastPageIndex; string baseUrl = "ManageBanners.aspx?search=" + Server.UrlEncode(txtSearch.Text) + "&p="; string navigateUrl; if (currentPagerIndex > 0) { //checks if the currentOager is a least two away from the Pager Index //in order fro the arrow to work if((currentPagerIndex - 2) > 0) { pagerLinkData.Add(new PagerLinkData("<<", baseUrl + "0", (currentPagerIndex - 2), true)); navigateUrl = baseUrl + (currentPagerIndex - 2).ToString(); pagerLinkData.Add(new PagerLinkData("<", navigateUrl, (currentPagerIndex - 2), true)); }//end of if else if((currentPagerIndex - 1) > 0) { navigateUrl = baseUrl + (currentPagerIndex - 2); pagerLinkData.Add(new PagerLinkData(((int)(currentPagerIndex - 1)).ToString(), navigateUrl, (currentPagerIndex - 2), true)); }//end of else if string linkText = ((int)(currentPagerIndex)).ToString(); navigateUrl = baseUrl + (currentPagerIndex - 1); pagerLinkData.Add(new PagerLinkData(linkText, navigateUrl, (currentPagerIndex - 1), true)); }//end of if while (currentPagerIndex <= lastPagerIndex) { string linkText = ((int)(currentPagerIndex + 1)).ToString(); if (currentPagerIndex != _HiddenPageIndex) { navigateUrl = baseUrl + currentPagerIndex.ToString(); pagerLinkData.Add(new PagerLinkData(linkText, navigateUrl, currentPagerIndex, (currentPagerIndex != _HiddenPageIndex))); }//end of if else { navigateUrl = "#"; pagerLinkData.Add(new PagerLinkData(linkText, navigateUrl, currentPagerIndex, (currentPagerIndex != _HiddenPageIndex), "divCurrentPage")); }//end of else currentPagerIndex++; }//end of while loop if (lastPagerIndex < _LastPageIndex) { navigateUrl = baseUrl + (lastPagerIndex + 1).ToString(); pagerLinkData.Add(new PagerLinkData(">", navigateUrl,lastPagerIndex+1, true)); }//end of if PagerControls.DataSource = pagerLinkData; PagerControls.DataBind(); }//end of if else PagerPanel.Visible = false; }//end of BindPagingControls()