/// <summary> /// 绑定TOP类控件 /// </summary> private void BindProductTop(Control c) { //声明变量 DataTable dtProductTop = null; //找到控件后,获取对应的数据集 string topName = c.ID.Substring(c.ID.IndexOf("_") + 1); ProductInfo.ProductTop pt = (ProductInfo.ProductTop)Enum.Parse(typeof(ProductInfo.ProductTop), topName); switch (pt) { case ProductInfo.ProductTop.New: case ProductInfo.ProductTop.Hot: case ProductInfo.ProductTop.Discount: dtProductTop = ProductBrowser.GetHomeProductTop(3, pt); break; case ProductInfo.ProductTop.MostLike: dtProductTop = ProductBrowser.GetHomeProductTop(5, pt); break; case ProductInfo.ProductTop.Activity: dtProductTop = ProductBrowser.GetHomeProductTop(2, pt); break; default: //dtProductTop = ProductBrowser.GetHomeProductTop(3, pt); break; } //数据集处理 switch (SettingsManager.GetMasterSettings(true).VTheme.ToLower()) { case "green": dtProductTop.Columns.Add("styleName", typeof(string)); for (int i = 0; i < dtProductTop.Rows.Count; i++) { dtProductTop.Rows[i]["styleName"] = (i % 2 == 0) ? "imgstye_l" : "imgstye_r"; } break; case "e0404": for (int i = 1; i <= dtProductTop.Rows.Count; i++) { dtProductTop.Rows[i - 1]["ProductName"] = ((i + 4) % 5 == 0) ? dtProductTop.Rows[i - 1]["ProductName"] : ""; } break; case "style01": switch (pt) { case ProductInfo.ProductTop.New: dtProductTop = ProductBrowser.GetHomeProductTop(4, pt); break; case ProductInfo.ProductTop.Discount: dtProductTop = ProductBrowser.GetHomeProductTop(3, pt); break; case ProductInfo.ProductTop.MostLike: dtProductTop = ProductBrowser.GetHomeProductTop(6, pt); break; } break; case "style02": case "style03": switch (pt) { case ProductInfo.ProductTop.Category: DataTable categories = CategoryBrowser.GetAllCategoriesRange(DistributorsBrower.GetCurrStoreProductRange()); if (categories.Rows.Count > 0) { int cateCount = categories.Rows.Count; //把总行数用变量储存起来,以免循环删除列后,rows总数会随时变动. //只保留dt的前三行 for (int i = 0; i < cateCount; i++) { if (categories.Rows.Count > 3) { categories.Rows.RemoveAt(3); } else { break; } } //绑定 dtProductTop = categories; //ProductBrowser.GetHomeProductTop("3", pt,Convert.ToInt32( categories.Rows[0]["categoryid"])); } break; case ProductInfo.ProductTop.New: dtProductTop = ProductBrowser.GetHomeProductTop(4, pt); break; case ProductInfo.ProductTop.MostLike: dtProductTop = ProductBrowser.GetHomeProductTop(5, pt); break; case ProductInfo.ProductTop.Discount: dtProductTop = ProductBrowser.GetHomeProductTop(3, ProductInfo.ProductTop.Hot); break; } break; case "bytype": break; } (c as VshopTemplatedRepeater).ItemDataBound += new RepeaterItemEventHandler(this.rptProductTop_ItemDataBound); //绑定 (c as VshopTemplatedRepeater).DataSource = dtProductTop; (c as VshopTemplatedRepeater).DataBind(); }