protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //fill categories dropDown if (ddlCategory.Items.Count == 0) { List <Category> categories = CategoryCollection.FetchAll(); ddlCategory.Items.Insert(0, new ListItem("-- please select --", "0")); foreach (var item in categories) { ddlCategory.Items.Add(new ListItem(item.CategoryName, item.CategoryId.ToString())); } } } int CurrentPageIndex = 0; if (!int.TryParse(hfCurrentPageIndex_dgSubCategories.Value, out CurrentPageIndex)) { CurrentPageIndex = 0; } if (CurrentPageIndex < 0) { CurrentPageIndex = 0; } dgSubCategories.CurrentPageIndex = CurrentPageIndex; LoadItems(); }
/// <summary> /// Returns all categories along with the uncategorized category /// </summary> /// <returns></returns> public CategoryCollection GetAllCachedCategories() { CategoryCollection cc = ZCache.Get <CategoryCollection>(CacheKey); if (cc == null) { cc = CategoryCollection.FetchAll(); bool foundUncategorized = false; foreach (Category c in cc) { if (c.Name == UncategorizedName) { foundUncategorized = true; break; } } if (!foundUncategorized) { Category uncategorizedCategory = new Category(); uncategorizedCategory.Name = UncategorizedName; uncategorizedCategory.LinkName = "uncategorized"; uncategorizedCategory.Save(); cc.Add(uncategorizedCategory); } ZCache.InsertCache(CacheKey, cc, 90); } return(cc); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //fill categories dropDown if (ddlCategory.Items.Count == 0) { List <Category> categories = CategoryCollection.FetchAll(); ddlCategory.Items.Insert(0, new ListItem("-- please select --", "0")); foreach (var item in categories) { ddlCategory.Items.Add(new ListItem(item.CategoryName, item.CategoryId.ToString())); } if (ddlCategory.SelectedItem != null) { ddlSubCategory.Items.Insert(0, new ListItem("-- please select --", "0")); } } } if (!Int64.TryParse(Request.QueryString[@"page"], out ProductPage)) { ProductPage = 0; } int CurrentPageIndex = 0; if (!int.TryParse(hfCurrentPageIndex_dgProducts.Value, out CurrentPageIndex)) { CurrentPageIndex = 0; } else if (ProductPage > 0) { CurrentPageIndex = (int)ProductPage; } // ProductPage = CurrentPageIndex; if (CurrentPageIndex < 0) { CurrentPageIndex = 0; } dgProducts.CurrentPageIndex = CurrentPageIndex; LoadItems(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //fill mainCategory ddl CategoryCollection categoryList = CategoryCollection.FetchAll(); foreach (var item in categoryList) { ddlCategory.Items.Add(new ListItem(item.CategoryName, item.CategoryId.ToString())); } if (ddlFilters.Items.Count == 0) { List <FilterUI> filters = ProductController.GetAllFilter(); foreach (var item in filters) { ddlFilters.Items.Add(new ListItem(item.FilterName, item.FilterId.ToString())); } } LoadView(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { LoadItem(); ddlAnimalType.DataSource = AnimalCollection.FetchAll(); ddlAnimalType.DataValueField = "AnimalId"; ddlAnimalType.DataTextField = "AnimalName"; ddlAnimalType.DataBind(); ddlAnimalType.Items.Insert(0, new ListItem(ProductsStrings.GetText("Choose"), "0")); ddlCategory.DataSource = CategoryCollection.FetchAll(); ddlCategory.DataValueField = "CategoryId"; ddlCategory.DataTextField = "CategoryName"; ddlCategory.DataBind(); ddlCategory.Items.Insert(0, new ListItem(ProductsStrings.GetText("Choose"), "0")); ddlSubCategory.Items.Insert(0, new ListItem(ProductsStrings.GetText("Choose"), "0")); } ScriptManager scriptManager = ScriptManager.GetCurrent(this.Page); scriptManager.RegisterPostBackControl(this.btnExport); }