public void DoSearch(string Company, string Height, string Width, string Radius, string Season) { List<TireWithPrice> sourceList = null; using (CmsDataContext cms = new CmsDataContext()) { try { //Алгоритм фильтрации 1) сначала выбираем все List<Tires> mQuery = null; IEnumerable<Tires> query = query = cms.Tires.Select(x => x); // 2)Выбираем только те, которые соответствуют названию производителя // 3)Выбираем только те, которые соответствуют заданной высоте if (!String.IsNullOrEmpty(Height) && !Height.ToLower().Contains("все")) query = query.Where(x => x.Height == Convert.ToDouble(Height)); // 4) и т.д. if (!String.IsNullOrEmpty(Width) && !Width.ToLower().Contains("все")) query = query.Where(x => x.Profile != null && x.Profile.ToString() == Width); if (!String.IsNullOrEmpty(Radius) && !Radius.ToLower().Contains("все")) query = query.Where(x => x.Radius != null && x.Radius.Contains(Radius)); if (!String.IsNullOrEmpty(Season) && !Season.ToLower().Contains("все")) query = query.Where(x => x.Season != null && x.Season.ToString().ToUpper() == Season.ToUpper()); if (!String.IsNullOrEmpty(Company) && !Company.ToLower().Contains("все")) //Проверяем нличие брэнда в метаданных и списке брендов он должен быть настроен видимым query = query.Where(x => x.Manufacturer != null && x.Manufacturer.ToUpper().Contains(Company.ToUpper()) && cms.TireBrands.Where(y => y.IsVisible).Select(y => y.Name.ToUpper()).Contains(Company.ToUpper())); else query = query.Where(x => x.Manufacturer != null && cms.TireBrands.Where(y => y.IsVisible).Select(y => y.Name.ToUpper()).Contains(x.Manufacturer.ToUpper())); //Конец фильтрации mQuery = query.ToList(); sourceList = (from n in mQuery select new TireWithPrice { Manufacturer = n.Manufacturer, ModelName = n.ModelName, Profile = n.Profile, Radius = n.Radius, Height = n.Height, Season = n.Season, TireIndex = n.TireIndex, Price = 0, Width = n.Profile, TireNumber = n.TireNumber, ImageUrl = n.ImageUrl, Ref = String.Format(UrlManager.GetSearchSparePartsUrl(n.Manufacturer.ToUpper(), n.TireNumber)) }).ToList(); } catch { } finally { if (cms.Connection.State == System.Data.ConnectionState.Open) cms.Connection.Close(); } } using (StoreDataContext store = new StoreDataContext()) { try { List<TireWithPrice> TirePriceSearchResult = new List<TireWithPrice>(); ExceedMaxresult = false; foreach (TireWithPrice item in sourceList) { List<SearchResultItem> list; if (Cache.Get(item.Manufacturer + item.TireNumber) == null) { PartKey searchPartKey = new PartKey(item.Manufacturer, item.TireNumber); SparePartItem[] parts = new SparePartItem[0]; if (item.Manufacturer != null) { //TODO: Рассмотреть применение последнего параметра -- поиска аналогов // со слов Беляева если нет уточнения по параметрам, т.е. зима, размер и т.д., то "поиск аналогов" в отношении шин не имеет смысла, // в связи с этим рассмотреть возможность передачи false в нижележащий метод: parts = PricingSearch.SearchSpareParts(item.TireNumber, item.Manufacturer.ToUpper(), true); } //пересчитать цены, подгрузить дополнительную информацию о деталях RmsAuto.Acctg.ClientGroup clientGroup = SiteContext.Current.CurrentClient.Profile.ClientGroup; decimal personalMarkup = SiteContext.Current.CurrentClient.Profile.PersonalMarkup; //var additionalInfos = RmsAuto.TechDoc.Facade.GetAdditionalInfo(new[] { searchPartKey }.Union(parts.Select(p => new PartKey(p.SparePart.Manufacturer, p.SparePart.PartNumber)))); //var additionalInfosExt = RmsAuto.Store.Entities.Helpers.SearchHelper.GetAdditionalInfoExt(parts.Select(p => new SparePartKeyExt(p.SparePart.Manufacturer, p.SparePart.PartNumber, p.SparePart.SupplierID))); //курс валюты CurrencyRate currencyRate = GetCurrentCurrencyRate(); list = parts.Select( p => new RmsAuto.Store.Web.Controls.SearchResultItem { ItemType = p.ItemType, SparePart = p.SparePart, AdditionalInfo = null,/*additionalInfos.ContainsKey(new PartKey(p.SparePart.Manufacturer, p.SparePart.PartNumber)) ? additionalInfos[new PartKey(p.SparePart.Manufacturer, p.SparePart.PartNumber)] : null,*/ AdditionalInfoExt = null, /*additionalInfosExt.ContainsKey(new SparePartKeyExt(p.SparePart.Manufacturer, p.SparePart.PartNumber, p.SparePart.SupplierID)) ? additionalInfosExt[new SparePartKeyExt(p.SparePart.Manufacturer, p.SparePart.PartNumber, p.SparePart.SupplierID)] : null,*/ FinalSalePriceRUR = p.SparePart.GetFinalSalePrice(clientGroup, personalMarkup), FinalSalePrice = p.SparePart.GetFinalSalePrice(clientGroup, personalMarkup) / currencyRate.Rate, ShowPrices = true, ShowInfo = true }).Where(p => p.FinalSalePriceRUR > 0).ToList(); //чтобы убрать позиции с нулевой ценой из результатов поиска Cache.Insert(item.Manufacturer + item.TireNumber, list, null, DateTime.UtcNow.AddMinutes(Convert.ToInt32(ConfigurationManager.AppSettings["CacheDuration"])), TimeSpan.Zero); } else { list = (List<SearchResultItem>)Cache.Get(item.Manufacturer + item.TireNumber); } if (TirePriceSearchResult.Count < MaxSearchCount) { foreach (var item2 in list) { TireWithPrice tmp = new TireWithPrice() { Radius = item.Radius, Height = item.Height, Manufacturer = item.Manufacturer, ModelName = item.ModelName, Price = item2.FinalSalePriceRUR, Profile = item.Profile, Ref = item.Ref, Season = item.Season, TireIndex = item.TireIndex, TireNumber = item.TireNumber, Width = item.Width, SparePart = item2.SparePart, ImageUrl = item.ImageUrl, }; TirePriceSearchResult.Add(tmp); break; } } else { ExceedMaxresult = true; break; } } //отсортировать результаты поиска CurrentSearchCount = TirePriceSearchResult.Count; PagedDataSource = new PagedDataSource(); PagedDataSource.DataSource = TirePriceSearchResult.OrderBy(x => x.Price).ToList(); PagedDataSource.AllowPaging = true; int count = 0; if (!String.IsNullOrEmpty(Request.Params["PageSize"]) && int.TryParse(Request.Params["PageSize"], out count)) { PagedDataSource.PageSize = Convert.ToInt32(Request.Params["PageSize"]); } if (PagedDataSource.PageSize == 0) { PagedDataSource.PageSize = 10; } TirePagerControl.Visible = TirePriceSearchResult.Count / PagedDataSource.PageSize + 1 > 1; //Установка значения пейджера if (TirePriceSearchResult.Count % PagedDataSource.PageSize > 0) TirePagerControl.MaxIndex = TirePriceSearchResult.Count / PagedDataSource.PageSize + 1; else TirePagerControl.MaxIndex = TirePriceSearchResult.Count / PagedDataSource.PageSize + 0; if (TirePagerControl.CurrentIndex > 0) { PagedDataSource.CurrentPageIndex = TirePagerControl.CurrentIndex - 1; rptSearchResults.DataSource = PagedDataSource; rptSearchResults.DataBind(); } if (TirePriceSearchResult.Count > 0) rptSearchResults.Visible = true; else { var labelResult = new Label(); labelResult.Style.Add(HtmlTextWriterStyle.FontWeight, "Bold"); labelResult.Style.Add(HtmlTextWriterStyle.Color, "Green"); labelResult.Text = "Ничего не найдено, попробуйте изменить параметры поиска."; _resultsPlaceHolder.Controls.Add(labelResult); rptSearchResults.Visible = false; } } catch(Exception ex) { Logger.WriteError("При поиске шин произошла ошибка.", EventLogerID.UnknownError, EventLogerCategory.UnknownCategory, ex); } finally { if (store.Connection.State == System.Data.ConnectionState.Open) { store.Connection.Close(); } } } }
public void DoSearch(string Company, string Width, string Diameter, string Gab) { List<Disc> mQuery = null; using (CmsDataContext cms = new CmsDataContext()) { try { //Алгоритм фильтрации 1) сначала выбираем все //IEnumerable<Disc> query = query = cms.Discs.Select(x => x); IEnumerable<Disc> query = cms.Discs.ToArray(); // 2)Выбираем только те, которые соответствуют названию производителя /*if (!String.IsNullOrEmpty(Company) && !Company.ToLower().Contains("все")) //Проверяем нличие брэнда в метаданных и списке брендов он должен быть настроен видимым query = query.Where(x => x.Manufacturer != null && x.Manufacturer.ToUpper().Contains(Company.ToUpper()) && cms.DiscBrands.Where(y => y.IsVisible).Select(y => y.Name.ToUpper()).Contains(Company.ToUpper())); else query = query.Where(x => x.Manufacturer != null && cms.DiscBrands.Where(y => y.IsVisible).Select(y => y.Name.ToUpper()).Contains(x.Manufacturer.ToUpper())); */ if (!String.IsNullOrEmpty(Company) && !Company.ToLower().Contains("все")) query = query.Where(x => x.Manufacturer.ToUpper() == Company.ToUpper()); // 3)Выбираем только те, которые соответствуют заданной высоте if (!String.IsNullOrEmpty(Width) && !Width.ToLower().Contains("все")) query = query.Where(x => x.Width == Convert.ToDecimal(Width.Replace('.', ','))); // 4) и т.д. if (!String.IsNullOrEmpty(Diameter) && !Diameter.ToLower().Contains("все")) query = query.Where(x => x.Diameter != null && x.Diameter == Convert.ToDecimal(Diameter)); if (!String.IsNullOrEmpty(Gab) && !Gab.ToLower().Contains("все")) { Gab = Gab.Replace(" ", ""); if (Gab.StartsWith("<")) query = query.Where(x => x.Gab <= Convert.ToDecimal(Gab.Split('<')[1])); else if (Gab.StartsWith(">")) query = query.Where(x => x.Gab >= Convert.ToDecimal(Gab.Split('>')[1])); else query = query.Where(x => x.Gab >= Convert.ToDecimal(Gab.Split('-')[0]) && x.Gab <= Convert.ToDecimal(Gab.Split('-')[1])); } //Конец фильтрации mQuery = query.ToList(); } catch { } finally { if (cms.Connection.State == System.Data.ConnectionState.Open) cms.Connection.Close(); } } using (var store = new StoreDataContext()) { try { List<Disc> BatteryPriceSearchResult = new List<Disc>(); ExceedMaxresult = false; foreach (Disc item in mQuery) { List<SearchResultItem> list; if (Cache.Get(item.Manufacturer + item.PartNumber) == null) { PartKey searchPartKey = new PartKey(item.Manufacturer, item.PartNumber); SparePartItem[] parts = new SparePartItem[0]; if (item.Manufacturer != null) { //TODO: Рассмотреть применение последнего параметра -- поиска аналогов parts = PricingSearch.SearchSpareParts(item.PartNumber, item.Manufacturer.ToUpper(), false); } //пересчитать цены, подгрузить дополнительную информацию о деталях RmsAuto.Acctg.ClientGroup clientGroup = SiteContext.Current.CurrentClient.Profile.ClientGroup; decimal personalMarkup = SiteContext.Current.CurrentClient.Profile.PersonalMarkup; var additionalInfos = RmsAuto.TechDoc.Facade.GetAdditionalInfo(new[] { searchPartKey }.Union(parts.Select(p => new PartKey(p.SparePart.Manufacturer, p.SparePart.PartNumber)))); // dan 01.06.2011 task4253 Механизм отображения фотографий брака в результатах поиска. var additionalInfosExt = RmsAuto.Store.Entities.Helpers.SearchHelper.GetAdditionalInfoExt( parts.Select(p => new SparePartKeyExt(p.SparePart.Manufacturer, p.SparePart.PartNumber, p.SparePart.SupplierID))); //курс валюты CurrencyRate currencyRate = GetCurrentCurrencyRate(); list = parts.Select( p => new RmsAuto.Store.Web.Controls.SearchResultItem { ItemType = p.ItemType, SparePart = p.SparePart, AdditionalInfo = additionalInfos.ContainsKey(new PartKey(p.SparePart.Manufacturer, p.SparePart.PartNumber)) ? additionalInfos[new PartKey(p.SparePart.Manufacturer, p.SparePart.PartNumber)] : null, // dan 01.06.2011 task4253 Механизм отображения фотографий брака в результатах поиска. AdditionalInfoExt = additionalInfosExt.ContainsKey(new SparePartKeyExt(p.SparePart.Manufacturer, p.SparePart.PartNumber, p.SparePart.SupplierID)) ? additionalInfosExt[new SparePartKeyExt(p.SparePart.Manufacturer, p.SparePart.PartNumber, p.SparePart.SupplierID)] : null, FinalSalePriceRUR = p.SparePart.GetFinalSalePrice(clientGroup, personalMarkup), FinalSalePrice = p.SparePart.GetFinalSalePrice(clientGroup, personalMarkup) / currencyRate.Rate, ShowPrices = true, ShowInfo = true }).Where(p => p.FinalSalePriceRUR > 0).ToList(); //dan 19.09.2011 добавил условие чтобы убрать позиции с нулевой ценой из результатов поиска Cache.Insert(item.Manufacturer + item.PartNumber, list, null, DateTime.UtcNow.AddMinutes(Convert.ToInt32(ConfigurationManager.AppSettings["CacheDuration"])), TimeSpan.Zero); } else { list = (List<SearchResultItem>)Cache.Get(item.Manufacturer + item.PartNumber); } if (BatteryPriceSearchResult.Count < MaxSearchCount) { foreach (var item2 in list) { Disc tmp = new Disc() { Dia = item.Dia, PCD = item.PCD, Gab = item.Gab, Manufacturer = item.Manufacturer, ModelName = item.ModelName, Diameter = item.Diameter, Width = item.Width, PartNumber = item.PartNumber, ImageUrl = item.ImageUrl, Price = item2.FinalSalePriceRUR, SparePart = item2.SparePart, Ref = String.Format(@"/SearchSpareParts.aspx?mfr={0}&pn={1}&st=1", item.Manufacturer.ToUpper(), item.PartNumber) }; BatteryPriceSearchResult.Add(tmp); break; //Ищем только одно предложение //TODO и зачем тут этот недостижимый участок кода??? if (BatteryPriceSearchResult.Count >= MaxSearchCount) { ExceedMaxresult = true; break; } } } else { ExceedMaxresult = true; break; } } //отсортировать результаты поиска CurrentSearchCount = BatteryPriceSearchResult.Count; PagedDataSource = new PagedDataSource(); PagedDataSource.DataSource = BatteryPriceSearchResult.OrderBy(x => x.Price).ToList(); PagedDataSource.AllowPaging = true; int count = 0; if (!String.IsNullOrEmpty(Request.Params["PageSize"]) && int.TryParse(Request.Params["PageSize"], out count)) { PagedDataSource.PageSize = Convert.ToInt32(Request.Params["PageSize"]); } if (PagedDataSource.PageSize == 0) { PagedDataSource.PageSize = 10; } TirePagerControl.Visible = BatteryPriceSearchResult.Count / PagedDataSource.PageSize + 1 > 1; //Установка значения пейджера if (BatteryPriceSearchResult.Count % PagedDataSource.PageSize > 0) TirePagerControl.MaxIndex = BatteryPriceSearchResult.Count / PagedDataSource.PageSize + 1; else TirePagerControl.MaxIndex = BatteryPriceSearchResult.Count / PagedDataSource.PageSize + 0; if (TirePagerControl.CurrentIndex > 0) { PagedDataSource.CurrentPageIndex = TirePagerControl.CurrentIndex - 1; rptSearchResults.DataSource = PagedDataSource; rptSearchResults.DataBind(); } if (BatteryPriceSearchResult.Count > 0) rptSearchResults.Visible = true; else { var labelResult = new Label(); labelResult.Style.Add(HtmlTextWriterStyle.FontWeight, "Bold"); labelResult.Style.Add(HtmlTextWriterStyle.Color, "Green"); labelResult.Text = "Ничего не найдено, попробуйте изменить параметры поиска."; _resultsPlaceHolder.Controls.Add(labelResult); rptSearchResults.Visible = false; } } catch (Exception ex) { Logger.WriteError(ex.Message, EventLogerID.BLException, EventLogerCategory.BLError); } finally { if (store.Connection.State == System.Data.ConnectionState.Open) { store.Connection.Close(); } } } }
public void Page_PreRender( object sender, EventArgs e ) { //if (!IsPostBack) //Для того, чтобы при добавлении позиции в корзину поиск не производился повторно //if(HttpContext.Current.Request.RequestType != "POST") //Поменяли чтобы при добавлении в корзину поиск не производился повторно и при этом работал пейджинг { if (!IsGuest) { TextItemControl_2.Visible = true; Label_2.Visible = true; } _guestPriceHint_TextItemControl.Visible = _discountNotes_TextItemControl.Visible = false; _callToManagerHint_TextItemControl.Visible = false; string partNumber = PricingSearch.NormalizePartNumber(EnteredPartNumber); if (!String.IsNullOrEmpty(partNumber) && !String.IsNullOrEmpty(Manufacturer)) { IEnumerable<SearchResultItem> list; //if (Cache.Get(partNumber+Manufacturer) == null) //{ SearchSparePartsLogDac.AddLog(DateTime.Now, partNumber, Manufacturer, Request.UserHostAddress); PartKey searchPartKey = new PartKey(Manufacturer, partNumber); var parts = PricingSearch.SearchSpareParts(partNumber, Manufacturer, SearchCounterParts); //исключить запрошенный артикул, если он поставляется указанным поставщиком if (ExcludeSupplierID != null) { parts = parts.Where(p => !(string.Compare(p.SparePart.PartNumber, partNumber, true) == 0 && string.Compare(p.SparePart.Manufacturer, Manufacturer, true) == 0 && p.SparePart.SupplierID == ExcludeSupplierID)).ToArray(); } _searchCodeLabel.Text = Server.HtmlEncode(string.Format("{0} ({1})", partNumber, Manufacturer)); _countLabel.Text = parts.Length.ToString(); _guestPriceHint_TextItemControl.Visible = _discountNotes_TextItemControl.Visible = IsGuest && parts.Length > 0; _callToManagerHint_TextItemControl.Visible = parts.Length == 0; //пересчитать цены, подгрузить дополнительную информацию о деталях RmsAuto.Acctg.ClientGroup clientGroup = SiteContext.Current.CurrentClient.Profile.ClientGroup; decimal personalMarkup = SiteContext.Current.CurrentClient.Profile.PersonalMarkup; var additionalInfos = RmsAuto.TechDoc.Facade.GetAdditionalInfo(new[] { searchPartKey }.Union(parts.Select(p => new PartKey(p.SparePart.Manufacturer, p.SparePart.PartNumber)))); // dan 01.06.2011 task4253 Механизм отображения фотографий брака в результатах поиска. var additionalInfosExt = RmsAuto.Store.Entities.Helpers.SearchHelper.GetAdditionalInfoExt(parts.Select(p => new SparePartKeyExt(p.SparePart.Manufacturer, p.SparePart.PartNumber, p.SparePart.SupplierID))); //курс валюты CurrencyRate currencyRate = GetCurrentCurrencyRate(); //получаем список "собственных складов наличия" List<int> ownStores = StoreRefCatalog.RefOwnStores.Items.Select(x => x.SupplierID).ToList(); ;//OrderBO.OwnStoresForSearchResults; /*var*/ list = parts.Select( p => new SearchResultItem { ItemType = p.ItemType, //выставляем признак относится ли деталь к собственным складам наличия IsOwnStore = ownStores.Contains(p.SparePart.SupplierID), SparePart = p.SparePart, AdditionalInfo = additionalInfos.ContainsKey(new PartKey(p.SparePart.Manufacturer, p.SparePart.PartNumber)) ? additionalInfos[new PartKey(p.SparePart.Manufacturer, p.SparePart.PartNumber)] : null, // dan 01.06.2011 task4253 Механизм отображения фотографий брака в результатах поиска. AdditionalInfoExt = additionalInfosExt.ContainsKey(new SparePartKeyExt(p.SparePart.Manufacturer, p.SparePart.PartNumber, p.SparePart.SupplierID)) ? additionalInfosExt[new SparePartKeyExt(p.SparePart.Manufacturer, p.SparePart.PartNumber, p.SparePart.SupplierID)] : null, FinalSalePriceRUR = p.SparePart.GetFinalSalePrice(clientGroup, personalMarkup), FinalSalePrice = p.SparePart.GetFinalSalePrice(clientGroup, personalMarkup) / currencyRate.Rate, SalePrice1 = p.SparePart.GetFinalSalePrice(DiscountGroup1, personalMarkup) / currencyRate.Rate, SalePrice2 = p.SparePart.GetFinalSalePrice(DiscountGroup2, personalMarkup) / currencyRate.Rate, SalePrice3 = p.SparePart.GetFinalSalePrice(DiscountGroup3, personalMarkup) / currencyRate.Rate, ShowPrices = true, ShowInfo = true }).Where(p => p.FinalSalePriceRUR > 0); //dan 19.09.2011 добавил условие чтобы убрать позиции с нулевой ценой из результатов поиска //добавить фиктивный запрошенный артикул в блок собственных складов наличия if (!list.Any(p => p.ItemType == SparePartItemType.Exact && p.IsOwnStore)) { AdditionalInfo additionalInfo = additionalInfos.ContainsKey(searchPartKey) ? additionalInfos[searchPartKey] : null; list = list.Union(new[]{ new SearchResultItem { ItemType = SparePartItemType.Exact, IsOwnStore = true, SparePart = new SparePartFranch { Manufacturer=searchPartKey.Manufacturer, PartNumber=searchPartKey.PartNumber, PartDescription = additionalInfo!=null ? additionalInfo.PartDescription : "" }, AdditionalInfo = additionalInfo, ShowPrices = false, ShowInfo = additionalInfo!=null, FinalSalePrice = -1 //по данной "фиктивной" цене, в следующем блоке мы будем понимать что в блок собственных складов наличия уже добавлен фиктивный артикул } }); } //добавить фиктивный запрошенный артикул (если запрошенного артикула нет среди собственных складов наличия) if (!list.Any(p => p.ItemType == SparePartItemType.Exact && p.FinalSalePrice != -1)) { AdditionalInfo additionalInfo = /*additionalInfos.ContainsKey(searchPartKey) ? additionalInfos[searchPartKey] : */ null; list = list.Union(new[]{ new SearchResultItem { ItemType = SparePartItemType.Exact, SparePart = new SparePartFranch { Manufacturer=searchPartKey.Manufacturer, PartNumber=searchPartKey.PartNumber, PartDescription = additionalInfo!=null ? additionalInfo.PartDescription : "" }, AdditionalInfo = additionalInfo, ShowPrices = false, ShowInfo = additionalInfo!=null } }); } //Cache.Insert(partNumber + Manufacturer, list, // null, // DateTime.UtcNow.AddMinutes(Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["SearchResultsCachDuration"])), // TimeSpan.Zero); //} //else //{ //list = (IEnumerable<SearchResultItem>)Cache.Get(partNumber+Manufacturer); _searchCodeLabel.Text = Server.HtmlEncode(string.Format("{0} ({1})", partNumber, Manufacturer)); int partsCount = list.Count() - list.Where(l => l.ItemType == SparePartItemType.Exact && l.FinalSalePrice <= 0).Count(); _countLabel.Text = partsCount.ToString(); _guestPriceHint_TextItemControl.Visible = _discountNotes_TextItemControl.Visible = IsGuest && partsCount > 0; _callToManagerHint_TextItemControl.Visible = partsCount == 0; //} //отсортировать результаты поиска var orderedList = SortSearchResults(list, _sortOptionsBox.SelectedValue); //подгрузить группы подсветки var groups = SparePartGroupsDac.GetSparePartGroups().ToDictionary(g => g.SparePartGroupID); var usedGroups = new List<SparePartGroup>(); foreach (var item in orderedList) { if (item.SparePart.SparePartGroupID.HasValue && groups.ContainsKey(item.SparePart.SparePartGroupID.Value)) { var group = groups[item.SparePart.SparePartGroupID.Value]; int index = usedGroups.IndexOf(group); if (index < 0) { index = usedGroups.Count; usedGroups.Add(group); } item.SparePartGroupIndex = index; item.SparePartGroup = usedGroups[index]; } } PagedDataSource = new PagedDataSource(); PagedDataSource.DataSource = orderedList; PagedDataSource.AllowPaging = true; PagedDataSource.PageSize = 100; ////Номер страницы можно передавать, например, методом GET. Отображение нужной страницы выглядит так: //try //{ // Int32? curIndex = !string.IsNullOrEmpty(Request.QueryString.Get("pageindex")) ? (int?)Convert.ToInt32(Request.QueryString.Get("pageindex")) : null; // if (curIndex != null) // if ((int)curIndex >= 0 || (int)curIndex <= PagedDataSource.DataSourceCount) // PagedDataSource.CurrentPageIndex = (int)curIndex; // else // PagedDataSource.CurrentPageIndex = 0; //} //catch (Exception) //{ // // строка в неверном формате //} //Установка значения пейджера _searchResultPager.Visible = orderedList.Length / PagedDataSource.PageSize + 1 > 1; if (orderedList.Length % PagedDataSource.PageSize > 0) { _searchResultPager.MaxIndex = orderedList.Length / PagedDataSource.PageSize + 1; } else { _searchResultPager.MaxIndex = orderedList.Length / PagedDataSource.PageSize + 0; } if (_searchResultPager.CurrentIndex > 0) { PagedDataSource.CurrentPageIndex = _searchResultPager.CurrentIndex - 1; _partsRepeater.DataSource = PagedDataSource; _partsRepeater.DataBind(); } //прибиндить результаты //_partsRepeater.DataSource = PagedDataSource; //_partsRepeater.DataBind(); //прибиндить легенду групп подсветки _usedGroupsRepeater.DataSource = usedGroups; _usedGroupsRepeater.DataBind(); } } }