private void SetPage(int id) { //to get the selected product from the database Prod_Model prod_model = new Prod_Model(); Product product = prod_model.Get_Prod(id); // fill all the textboxes txtDescription.Text = product.Description; txtName.Text = product.Name; txtPrice.Text = product.Price.ToString(); // to set the values of the dropdown list ddlImage.SelectedValue = product.Image; ddlTypes.SelectedValue = product.TypeId.ToString(); }
private void setPage() { //get the current product details if (!string.IsNullOrWhiteSpace(Request.QueryString["id"])) { int id = Convert.ToInt32(Request.QueryString["id"]); Prod_Model prod_item = new Prod_Model(); Product product = prod_item.Get_Prod(id); //setup cuurent page lblPrice.Text = "Unit price: <br/>£ " + product.Price; lblTitle.Text = product.Name; lblDesc.Text = product.Description; lblIDno.Text = product.Id.ToString(); imgProd.ImageUrl = "~/Images/ProductImg/" + product.Image; //to fill the amout ddl box with amt of nos. from 1-20 int[] noofitems = Enumerable.Range(1, 20).ToArray(); ddlAmt.DataSource = noofitems; ddlAmt.AppendDataBoundItems = true; ddlAmt.DataBind(); } }
private void OrganiseCartWindow(List <Cart> orderList, out double AmtTotal) { AmtTotal = new Double(); Prod_Model type = new Prod_Model(); foreach (Cart cart in orderList) { //get databse data o fill page Product product = type.Get_Prod(cart.ProductID); //for the item image ImageButton buttonImage = new ImageButton { ImageUrl = string.Format("~/Images/ProductImg/{0}", product.Image), PostBackUrl = string.Format("~/Pages/Item.aspx?id={0}", product.Id) }; // delete cart items LinkButton linkDelete = new LinkButton { PostBackUrl = string.Format("~/Pages/Trolley.aspx?productId={0}", cart.ID), Text = "Remove Item", ID = "no" + cart.ID, }; //onclick events linkDelete.Click += Remove_Product; //Make a dropdownlist //list from numbers 1-20 int[] itemamount = Enumerable.Range(1, 20).ToArray(); DropDownList dropdownlistAmnt = new DropDownList { DataSource = itemamount, AppendDataBoundItems = true, AutoPostBack = true, ID = cart.ID.ToString() }; dropdownlistAmnt.DataBind(); dropdownlistAmnt.SelectedValue = cart.Amount.ToString(); dropdownlistAmnt.SelectedIndexChanged += dropdownlistAmnt_SelectdIndxChang; //populate cart details table with data //this is for table with 2 rows.. called lane Table datawindow = new Table { CssClass = "CartWindow" }; TableRow laneA = new TableRow(); TableRow laneB = new TableRow(); //create a six celled row for the first row.. called pane TableCell pane1 = new TableCell { RowSpan = 2, Width = 51 }; TableCell pane2 = new TableCell { Text = string.Format("<h4>{0}</h4><br />{1}<br/>Item In Stock", product.Name, "Product No:" + product.Id), HorizontalAlign = HorizontalAlign.Left, Width = 351, }; TableCell pane3 = new TableCell { Text = "Price per Unit<hr/>" }; TableCell pane4 = new TableCell { Text = "Quantity<hr/>" }; TableCell pane5 = new TableCell { Text = "Item *Total<hr/>" }; TableCell pane6 = new TableCell(); //to create a six celled row for the second row.. called panea..z TableCell panea1 = new TableCell(); TableCell paneb2 = new TableCell { Text = "£ " + product.Price }; TableCell panec3 = new TableCell(); TableCell paned4 = new TableCell { Text = "£ " + Math.Round((cart.Amount * (double)product.Price)) }; TableCell panee5 = new TableCell(); TableCell panef6 = new TableCell(); //Set customized controls pane1.Controls.Add(buttonImage); pane6.Controls.Add(linkDelete); panec3.Controls.Add(dropdownlistAmnt); //make some rows & cells to table laneA.Cells.Add(pane1); laneA.Cells.Add(pane2); laneA.Cells.Add(pane3); laneA.Cells.Add(pane4); laneA.Cells.Add(pane5); laneA.Cells.Add(pane6); laneB.Cells.Add(panea1); laneB.Cells.Add(paneb2); laneB.Cells.Add(panec3); laneB.Cells.Add(paned4); laneB.Cells.Add(panee5); laneB.Cells.Add(panef6); //create rows datawindow.Rows.Add(laneA); datawindow.Rows.Add(laneB); //display created table in panel paneltrolley.Controls.Add(datawindow); //Add total of current purchased item to subtotal AmtTotal += (cart.Amount * (double)product.Price); } //Add the utems to session Session[User.Identity.GetUserId()] = orderList; }