protected void Page_Load(object sender, EventArgs e) { ProcessGetProductsBySubCategoryId processProducts = new ProcessGetProductsBySubCategoryId(); processProducts.SubCategoryId = 1; try { processProducts.Invoke(); } catch (Exception ex) { Response.Write(ex); } this.dlProducts.DataSource = processProducts.Products; this.dlProducts.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { //dependent on what params are available, accept no Id, ProductCategoryId or ProductCategoryId + SubCategoryId Collection<ProductCollection> products = new Collection<ProductCollection>(); ProcessGetProductsByCategoryId productsCatId = new ProcessGetProductsByCategoryId(); ProcessGetProductsBySubCategoryId productsSubId = new ProcessGetProductsBySubCategoryId(); if (this.SubCategoryId != null) { productsSubId.SubCategoryId = Convert.ToInt32(this.SubCategoryId); try { productsSubId.Invoke(); } catch (Exception ex) { Response.Write(ex); } this.lvProductList.DataSource = productsSubId.Products; this.lvProductList.DataBind(); } else if (this.SubCategoryId == null && this.ProductCategoryId != null) { productsCatId.CategoryId = Convert.ToInt32(this.ProductCategoryId); try { productsCatId.Invoke(); } catch (Exception ex) { Response.Write(ex); } this.lvProductList.DataSource = productsCatId.Products; this.lvProductList.DataBind(); } }