protected void Page_Load(object sender, EventArgs e) { shop.Name = "Norwegian Jewellery and Loan"; shop.Sellers.Add(new Seller { FirstName = "Robert", LastName = "Ford" }); shop.Sellers.Add(new Seller { FirstName = "Jesse", LastName = "James" }); shop.Products.Add(new Merchandise { Name = "55 LED-TV Full HD", Description = " Full HD (1920 x 1080p), USB, Chromecast port," + " Smaart-tv", Price = 3699.99M, Merchant = shop.Sellers[0] }); shop.Products.Add(new Merchandise { Name = "Roof Lamp Milo", Description = " Roof lamp with bright pink glass. Height: 24 cm", Price = 529M, Merchant = shop.Sellers[0] }); shop.Products.Add(new Merchandise { Name = "Pillow Nagano", Description = "Handcrafted decorative pillow in silk/linen.", Price = 949M, Merchant = shop.Sellers[1] }); shop.Products.Add(new Merchandise { Name = "Cotton Carpet Cochin", Description = "Soft cotton carpet with fringes on the short sides. 200x300 cm.", Price = 879M, Merchant = shop.Sellers[1] }); if (!IsPostBack) { ListBoxProducts.DataTextField = "Display"; ListBoxProducts.DataValueField = "Display"; ListBoxProducts.DataSource = shop.Products; ListBoxProducts.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { shop.Name = "Norwegian Jewellery and Loan"; string connectionString = @"Data Source=localhost; Database=asp_webshop_db; User ID=root; Password=''"; using (cn = new MySqlConnection(connectionString)) { cn.Open(); //HttpContext.Current.Response.Write("Mysql Connection successful"); } Products = SelectMerchandise(); shop.Products.Add(new Merchandise { MerchandiseID = decimal.Parse(Products[0][0]), Name = Products[1][0], Description = Products[2][0], Price = decimal.Parse(Products[3][0]) }); shop.Products.Add(new Merchandise { MerchandiseID = decimal.Parse(Products[0][1]), Name = Products[1][1], Description = Products[2][1], Price = decimal.Parse(Products[3][1]) }); shop.Products.Add(new Merchandise { MerchandiseID = decimal.Parse(Products[0][2]), Name = Products[1][2], Description = Products[2][2], Price = decimal.Parse(Products[3][2]) }); shop.Products.Add(new Merchandise { MerchandiseID = decimal.Parse(Products[0][3]), Name = Products[1][3], Description = Products[2][3], Price = decimal.Parse(Products[3][3]) }); Sellers = SelectSellers(); shop.Sellers.Add(new Seller { FirstName = Sellers[2][0], LastName = Sellers[3][0] }); shop.Sellers.Add(new Seller { FirstName = Sellers[2][2], LastName = Sellers[3][2] }); if (!IsPostBack) { ListBoxProducts.DataTextField = "Display"; ListBoxProducts.DataValueField = "Display"; ListBoxProducts.DataSource = shop.Products; ListBoxProducts.DataBind(); } }