protected void Page_Load(object sender, EventArgs e) { if (Session["AdministratorID"] == null) Response.Redirect("~/Admin/Login.aspx"); else { if (!Page.IsPostBack) { //Populate the featured product dropdowns Product prod = new Product(); List<Product> products = prod.GetAllProducts(true); DropDownListFeaturedProduct1.DataSource = products; DropDownListFeaturedProduct1.DataTextField = "ProductCode"; DropDownListFeaturedProduct1.DataValueField = "ProductCode"; DropDownListFeaturedProduct1.DataBind(); Configuration config1 = new Configuration(); config1.GetConfigurationByCode("xFeaturedProduct1"); DropDownListFeaturedProduct1.SelectedValue = config1.Value.ToString(); DropDownListFeaturedProduct2.DataSource = products; DropDownListFeaturedProduct2.DataTextField = "ProductCode"; DropDownListFeaturedProduct2.DataValueField = "ProductCode"; DropDownListFeaturedProduct2.DataBind(); Configuration config2 = new Configuration(); config2.GetConfigurationByCode("xFeaturedProduct2"); DropDownListFeaturedProduct2.SelectedValue = config2.Value.ToString(); DropDownListFeaturedProduct3.DataSource = products; DropDownListFeaturedProduct3.DataTextField = "ProductCode"; DropDownListFeaturedProduct3.DataValueField = "ProductCode"; DropDownListFeaturedProduct3.DataBind(); Configuration config3 = new Configuration(); config3.GetConfigurationByCode("xFeaturedProduct3"); DropDownListFeaturedProduct3.SelectedValue = config3.Value.ToString(); DropDownListFeaturedProduct4.DataSource = products; DropDownListFeaturedProduct4.DataTextField = "ProductCode"; DropDownListFeaturedProduct4.DataValueField = "ProductCode"; DropDownListFeaturedProduct4.DataBind(); Configuration config4 = new Configuration(); config4.GetConfigurationByCode("xFeaturedProduct4"); DropDownListFeaturedProduct4.SelectedValue = config4.Value.ToString(); } } }
private void reloadGridView() { if (DropDownListDBTables.SelectedValue == "Administrators") { //Get all objects Administrator obj = new Administrator(); List<Administrator> list = obj.GetAllAdministrators(false); //Fill a rendered object list List<RenderAdministrator> renderedList = new List<RenderAdministrator>(); foreach (Administrator x in list) { renderedList.Add(new RenderAdministrator(x)); } GridViewDBTable.DataSource = renderedList; } else if (DropDownListDBTables.SelectedValue == "Audits") { //Get all objects Audit obj = new Audit(); List<Audit> list = obj.GetAllAudits(); //Fill a rendered object list List<RenderAudit> renderedList = new List<RenderAudit>(); foreach (Audit x in list) { renderedList.Add(new RenderAudit(x)); } GridViewDBTable.DataSource = renderedList; } else if (DropDownListDBTables.SelectedValue == "AuditTypes") { //Get all objects AuditType obj = new AuditType(); List<AuditType> list = obj.GetAllAuditTypes(); //Fill a rendered object list List<RenderAuditType> renderedList = new List<RenderAuditType>(); foreach (AuditType x in list) { renderedList.Add(new RenderAuditType(x)); } GridViewDBTable.DataSource = renderedList; } if (DropDownListDBTables.SelectedValue == "Categories") { //Get all objects Category obj = new Category(); List<Category> list = obj.GetAllCategories(false); //Fill a rendered object list List<RenderCategory> renderedList = new List<RenderCategory>(); foreach (Category x in list) { renderedList.Add(new RenderCategory(x)); } GridViewDBTable.DataSource = renderedList; } else if (DropDownListDBTables.SelectedValue == "Configurations") { //Get all objects Configuration obj = new Configuration(); List<Configuration> list = obj.GetAllConfigurations(); //Fill a rendered object list List<RenderConfiguration> renderedList = new List<RenderConfiguration>(); foreach (Configuration x in list) { renderedList.Add(new RenderConfiguration(x)); } GridViewDBTable.DataSource = renderedList; } else if (DropDownListDBTables.SelectedValue == "DeliveryType") { //Get all objects DeliveryType obj = new DeliveryType(); List<DeliveryType> list = obj.GetAllDeliveryTypes(); //Fill a rendered object list List<RenderDeliveryType> renderedList = new List<RenderDeliveryType>(); foreach (DeliveryType x in list) { renderedList.Add(new RenderDeliveryType(x)); } GridViewDBTable.DataSource = renderedList; } else if (DropDownListDBTables.SelectedValue == "LangLabels") { //Get all objects LangLabel obj = new LangLabel(); List<LangLabel> list = obj.GetAllLangLabels(); //Fill a rendered object list List<RenderLangLabel> renderedList = new List<RenderLangLabel>(); foreach (LangLabel x in list) { renderedList.Add(new RenderLangLabel(x)); } GridViewDBTable.DataSource = renderedList; } else if (DropDownListDBTables.SelectedValue == "OrderItems") { //Get all objects OrderItem obj = new OrderItem(); List<OrderItem> list = obj.GetAllOrderItems(); //Fill a rendered object list List<RenderOrderItem> renderedList = new List<RenderOrderItem>(); foreach (OrderItem x in list) { renderedList.Add(new RenderOrderItem(x)); } GridViewDBTable.DataSource = renderedList; } else if (DropDownListDBTables.SelectedValue == "Orders") { //Get all objects Order obj = new Order(); List<Order> list = obj.GetAllOrders(); //Fill a rendered object list List<RenderOrder> renderedList = new List<RenderOrder>(); foreach (Order x in list) { renderedList.Add(new RenderOrder(x)); } GridViewDBTable.DataSource = renderedList; } else if (DropDownListDBTables.SelectedValue == "ProductDeliveryTypes") { //Get all objects ProductDeliveryType obj = new ProductDeliveryType(); List<ProductDeliveryType> list = obj.GetAllProductDeliveryTypes(); //Fill a rendered object list List<RenderProductDeliveryType> renderedList = new List<RenderProductDeliveryType>(); foreach (ProductDeliveryType x in list) { renderedList.Add(new RenderProductDeliveryType(x)); } GridViewDBTable.DataSource = renderedList; } else if (DropDownListDBTables.SelectedValue == "Products") { //Get all objects Product obj = new Product(); List<Product> list = obj.GetAllProducts(false); //Fill a rendered object list List<RenderProduct> renderedList = new List<RenderProduct>(); foreach(Product x in list) { renderedList.Add(new RenderProduct(x)); } GridViewDBTable.DataSource = renderedList; } else if (DropDownListDBTables.SelectedValue == "StatesProvinces") { //Get all objects StateProvince obj = new StateProvince(); List<StateProvince> list = obj.GetAllStatesProvinces(); //Fill a rendered object list List<RenderStateProvince> renderedList = new List<RenderStateProvince>(); foreach (StateProvince x in list) { renderedList.Add(new RenderStateProvince(x)); } GridViewDBTable.DataSource = renderedList; } else if (DropDownListDBTables.SelectedValue == "Users") { //Get all objects User obj = new User(); List<User> list = obj.GetAllUsers(); //Fill a rendered object list List<RenderUser> renderedList = new List<RenderUser>(); foreach (User x in list) { renderedList.Add(new RenderUser(x)); } GridViewDBTable.DataSource = renderedList; } //Databind the new datasource obtained above GridViewDBTable.DataBind(); }
protected void UpdatePanel1_Load(object sender, EventArgs e) { //Populate products grid Product product = new Product(); DataTable dataTable = product.ToDataTable(product.GetAllProducts(false)); GridViewProducts.DataSource = dataTable; GridViewProducts.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { //Load the slider images and details Configuration config = new Configuration(); Product prod = new Product(); //Slide 1 config.GetConfigurationByCode("xFeaturedProduct1"); prod.GetProductByCode(config.Value.ToString()); //Attempt to display image (if it is found) try { ImageFeatured1.Src = "~/Images/Product_Images/" + prod.ProductCode + ".jpg"; } catch (Exception) { ImageFeatured1.Src = ""; } LabelFeaturedBrand1.Text = prod.Brand.ToString(); LabelFeaturedName1.Text = prod.Name.ToString(); LabelFeaturedPrice1.Text = "Only $" + prod.Msrp.ToString(); LinkButtonFeatured1.PostBackUrl = "~/ProductInfo.aspx?prodcd=" + prod.ProductCode.ToString(); //Slide 2 config.GetConfigurationByCode("xFeaturedProduct2"); prod.GetProductByCode(config.Value.ToString()); //Attempt to display image (if it is found) try { ImageFeatured2.Src = "~/Images/Product_Images/" + prod.ProductCode + ".jpg"; } catch (Exception) { ImageFeatured2.Src = ""; } LabelFeaturedBrand2.Text = prod.Brand.ToString(); LabelFeaturedName2.Text = prod.Name.ToString(); LabelFeaturedPrice2.Text = "Only $" + prod.Msrp.ToString(); //Slide 3 config.GetConfigurationByCode("xFeaturedProduct3"); prod.GetProductByCode(config.Value.ToString()); //Attempt to display image (if it is found) try { ImageFeatured3.Src = "~/Images/Product_Images/" + prod.ProductCode + ".jpg"; } catch (Exception) { ImageFeatured3.Src = ""; } LabelFeaturedBrand3.Text = prod.Brand.ToString(); LabelFeaturedName3.Text = prod.Name.ToString(); LabelFeaturedPrice3.Text = "Only $" + prod.Msrp.ToString(); //Slide 4 config.GetConfigurationByCode("xFeaturedProduct4"); prod.GetProductByCode(config.Value.ToString()); //Attempt to display image (if it is found) try { ImageFeatured4.Src = "~/Images/Product_Images/" + prod.ProductCode + ".jpg"; } catch (Exception) { ImageFeatured4.Src = ""; } LabelFeaturedBrand4.Text = prod.Brand.ToString(); LabelFeaturedName4.Text = prod.Name.ToString(); LabelFeaturedPrice4.Text = "Only $" + prod.Msrp.ToString(); //Load the data list (THIS IS A TEMPORARY WAY...CHOOSES FIRST 6 PRODUCTS) List<Product> allProducts = new List<Product>(); allProducts = prod.GetAllProducts(true); List<Product> frontpageProducts = new List<Product>(); for (int i = 0; i < 6; i++) { frontpageProducts.Add(allProducts[i]); } DataListProducts.DataSource = frontpageProducts; DataListProducts.DataBind(); }