private void BindCatalogNodesList() { IList <CatalogNode> catalogNodes = new List <CatalogNode>(); foreach (CatalogNode catalogNode in _CatalogNodes) { catalogNodes.Add(catalogNode); } CatalogNodeList.DataSource = catalogNodes; CatalogNodeList.DataBind(); }
protected void BindResultHeader() { //UPDATE THE RESULT INDEX MESSAGE int startRowIndex = (_pageSize * _HiddenPageIndex); int endRowIndex = startRowIndex + _pageSize; if (endRowIndex > _searchResultCount) { endRowIndex = _searchResultCount; } if (_searchResultCount == 0) { startRowIndex = -1; } ResultIndexMessage.Text = string.Format(ResultIndexMessage.Text, (startRowIndex + 1), endRowIndex, _searchResultCount); CatalogNodeList.DataSource = _ContentNodes; CatalogNodeList.DataBind(); }
protected void QuickSort_SelectedIndexChanged(object sender, EventArgs e) { IList <CatalogNode> catalogNodes = new List <CatalogNode>(); foreach (CatalogNode catalogNode in _CatalogNodes) { catalogNodes.Add(catalogNode); } switch (QuickSort.SelectedIndex) { case 2: catalogNodes.Sort("Name", CommerceBuilder.Common.SortDirection.DESC); break; default: catalogNodes.Sort("Name", CommerceBuilder.Common.SortDirection.ASC); break; } CatalogNodeList.DataSource = catalogNodes; CatalogNodeList.DataBind(); QuickSort.SelectedIndex = 0; }
protected void BindResultHeader() { //UPDATE THE RESULT INDEX MESSAGE int startRowIndex = (_pageSize * _hiddenPageIndex); int endRowIndex = startRowIndex + _pageSize; if (endRowIndex > _contentNodes.Count) { endRowIndex = _contentNodes.Count; } if (_contentNodes.Count == 0) { startRowIndex = -1; } IList <CatalogNode> bindNodes = new List <CatalogNode>(); ResultIndexMessage.Text = string.Format(ResultIndexMessage.Text, (startRowIndex + 1), endRowIndex, _contentNodes.Count); for (int i = startRowIndex; i < endRowIndex; i++) { bindNodes.Add(_contentNodes[i]); } CatalogNodeList.DataSource = bindNodes; CatalogNodeList.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { // SET THE DEFAULT PAGE SIZE AND ADD A NEW OPTION BASED ON MaxItems parameter value if needed if (!Page.IsPostBack) { CategoryBreadCrumbs1.Visible = this.DisplayBreadCrumbs; } InitializePageSize(); if (IsValidCategory()) { string eventTarget = Request["__EVENTTARGET"]; if (string.IsNullOrEmpty(eventTarget) || !eventTarget.EndsWith("PageSizeOptions")) { PageSizeOptions.ClearSelection(); ListItem item = PageSizeOptions.Items.FindByValue(_pageSize.ToString()); if (item != null) { item.Selected = true; } } if (string.IsNullOrEmpty(eventTarget) || !eventTarget.EndsWith("SortResults")) { string sortOption = Request.QueryString["s"]; if (!string.IsNullOrEmpty(sortOption)) { SortResults.ClearSelection(); ListItem item = SortResults.Items.OfType <ListItem>().FirstOrDefault(x => string.Compare(x.Value, sortOption, StringComparison.InvariantCultureIgnoreCase) == 0); if (item != null) { item.Selected = true; } } } if (!string.IsNullOrEmpty(eventTarget)) { if (eventTarget.EndsWith("PageSizeOptions") || eventTarget.EndsWith("SortResults")) { string url = Request.RawUrl; if (url.Contains("?")) { url = Request.RawUrl.Substring(0, Request.RawUrl.IndexOf("?")); } url += "?s=" + SortResults.SelectedValue; url += "&ps=" + _pageSize.ToString(); Response.Redirect(url); } } Caption.Text = this.DefaultCaption; if (_Category != null) { // use category name if no default name is specified if (string.IsNullOrEmpty(Caption.Text)) { Caption.Text = _Category.Name; } CategoryBreadCrumbs1.CategoryId = this.CategoryId; if (!string.IsNullOrEmpty(_Category.Summary) && ShowSummary) { CategorySummary.Text = _Category.Summary; } if (!string.IsNullOrEmpty(_Category.Description) && ShowDescription) { CategoryDescriptionPanel.Visible = true; CategoryDescription.Text = _Category.Description; } else { CategoryDescriptionPanel.Visible = false; } } else { // IT IS ROOT CATEGORY CategoryBreadCrumbs1.CategoryId = this.CategoryId; if (ShowSummary) { CategorySummary.Text = DefaultCategorySummary; } } if (_Category != null) { int count = WebpageDataSource.CountForCategory(_Category.Id, true, true); if (count > 0) { _currentPageIndex = AlwaysConvert.ToInt(Request.QueryString["p"]); if (_pageSize == 0) { _lastPageIndex = 0; } else { _lastPageIndex = ((int)Math.Ceiling(((double)count / (double)_pageSize))) - 1; } CatalogNodeList.DataSource = WebpageDataSource.LoadForCategory(_Category.Id, true, true, SortResults.SelectedValue, _pageSize, (_currentPageIndex * _pageSize)); CatalogNodeList.DataBind(); int startRowIndex = (_pageSize * _currentPageIndex); int endRowIndex = startRowIndex + _pageSize; if (endRowIndex > count || endRowIndex == 0) { endRowIndex = count; } if (count == 0) { startRowIndex = -1; } ResultIndexMessage.Text = string.Format(ResultIndexMessage.Text, (startRowIndex + 1), endRowIndex, count); ResultIndexMessage.Text = string.Format(ResultIndexMessage.Text, (startRowIndex + 1), endRowIndex, count); BindPagingControls(); } else { phEmptyCategory.Visible = true; } AbleCommerce.Code.PageVisitHelper.RegisterPageVisit(_Category.Id, CatalogNodeType.Category, _Category.Name); } } }
protected void Page_Load(object sender, EventArgs e) { CategoryBreadCrumbs1.Visible = DisplayBreadCrumbs; CategoryBreadCrumbs1.CategoryId = this.CategoryId; //BIND THE DISPLAY ELEMENTS if (IsValidCategory()) { if (_Category != null) { Caption.Text = _Category.Name; if (!string.IsNullOrEmpty(_Category.Summary) && ShowSummary) { CategorySummaryPanel.Visible = true; CategorySummary.Text = _Category.Summary; } else { CategorySummaryPanel.Visible = false; } if (!string.IsNullOrEmpty(_Category.Description) && ShowDescription) { CategoryDescriptionPanel.Visible = true; CategoryDescription.Text = _Category.Description; } else { CategoryDescriptionPanel.Visible = false; } } else { // IF IT IS ROOT CATEGORY Caption.Text = DefaultCaption; } BindSubCategories(); if (_Category != null) { //UPDATE THE RESULT INDEX MESSAGE _totalProducts = ProductDataSource.CountForCategory(true, _Category.Id, false, true); } //INITIALIZE PAGING VARIABLES InitializePagingVars(false); int startRowIndex = (_PageSize * _HiddenPageIndex); int endRowIndex = startRowIndex + _PageSize; if (endRowIndex > _totalProducts) { endRowIndex = _totalProducts; } if (_totalProducts == 0) { startRowIndex = -1; } ResultIndexMessage.Text = string.Format(ResultIndexMessage.Text, (startRowIndex + 1), endRowIndex, _totalProducts); if (_Category != null) { var products = ProductDataSource.LoadForCategory(true, _Category.Id, false, true, SortResults.SelectedValue, PageSize, startRowIndex); if (products.Count > 0) { var productIds = products.Select(p => p.Id) .ToList <int>(); var futureQuery = NHibernateHelper.QueryOver <Product>() .AndRestrictionOn(p => p.Id).IsIn(productIds) .Fetch(p => p.Manufacturer).Eager .Fetch(p => p.Specials).Eager .Future <Product>(); NHibernateHelper.QueryOver <Product>() .AndRestrictionOn(p => p.Id).IsIn(productIds) .Fetch(p => p.ProductOptions).Eager .Future <Product>(); NHibernateHelper.QueryOver <Product>() .AndRestrictionOn(p => p.Id).IsIn(productIds) .Fetch(p => p.ProductKitComponents).Eager .Future <Product>(); NHibernateHelper.QueryOver <Product>() .AndRestrictionOn(p => p.Id).IsIn(productIds) .Fetch(p => p.ProductTemplates).Eager .Future <Product>(); NHibernateHelper.QueryOver <Product>() .AndRestrictionOn(p => p.Id).IsIn(productIds) .Fetch(p => p.Reviews).Eager .Future <Product>(); futureQuery.ToList(); } CatalogNodeList.DataSource = products; CatalogNodeList.DataBind(); } if (_totalProducts > 0) { phCategoryContents.Visible = true; //BIND THE PAGING CONTROLS FOOTER BindPagingControls(); } else { ResultIndexMessage.Text = string.Format(ResultIndexMessage.Text, 0, 0, 0); //HIDE THE CONTENTS phCategoryContents.Visible = false; phEmptyCategory.Visible = (_Category != null && _Category.CatalogNodes.Count == 0); phNoSearchResults.Visible = !phEmptyCategory.Visible; } //UPDATE AJAX PANEL SearchResultsAjaxPanel.Update(); } else { CategoryHeaderPanel.Visible = false; } int manufecturerCount = ManufacturerDataSource.CountAll(); foreach (ListItem li in SortResults.Items) { if (li.Value.StartsWith("Manufacturer")) { li.Enabled = manufecturerCount > 0; } } }