protected void Page_Load(object sender, EventArgs e) { if (Request.Params["itemid"] != null && Request.Params["vendorid"] != null && !IsPostBack ) { //they passed in a product ID and a vendorid I can continue Item myItem = new Item(); myItem.Id = Request.Params["itemid"]; myItem.VendorId = int.Parse(Request.Params["vendorid"]); ItemDA myIDA = new ItemDA(); txtID.Text = myIDA.Get(myItem)[0].Id; txtPrice.Text = myIDA.Get(myItem)[0].Price.ToString(); //myIDA.dispose(); //myItem.dispose(); myIDA = null; myItem = null; } }
protected void Page_Load(object sender, EventArgs e) { // method that gets items in controls and // checks weather the sales price label is invisible or not GetItems(); try { if (Request.QueryString["ItemID"] != null) { // get item information based on itemID Item item = new Item(); item.Id = Request.QueryString["ItemID"]; ItemDA itemDA = new ItemDA(); Collection<Item> getItem = itemDA.Get(item); RangeValidator range = (RangeValidator)FormView1.FindControl("rvQuantity"); // if quantity available is less than minquanitity make txtQuantity and btnAddToCart invisible // and display Item is on Back order message. if (getItem[0].QuantityAvailable < getItem[0].MinQuantity) { range.MaximumValue = "0"; range.MinimumValue = "0"; quantity.ReadOnly = true; Button addtocart = (Button)FormView1.FindControl("btnAddToCart"); addtocart.Visible = false; error.Text = "Item is on backorder!"; error.Visible = true; quantity.Visible = false; Label lblquantity = (Label)FormView1.FindControl("lblQuantity"); lblquantity.Visible = false; } else { range.MaximumValue = getItem[0].QuantityAvailable.ToString(); range.MinimumValue = getItem[0].MinQuantity.ToString(); } //clear item = null; itemDA = null; getItem = null; } } catch (HttpException) { } catch (SqlException) { } }