protected void Page_Load(object sender, EventArgs e) { // Obtain categoryId from QueryString int categoryId = Int32.Parse(Request.Params["CategoryID"]); // Obtain products and databind to an asp:datalist control AWC.BusinessLayer.Products productCatalogue = new AWC.BusinessLayer.Products(); MyList.DataSource = productCatalogue.GetProducts(categoryId); MyList.DataBind(); }
//******************************************************* // // The Page_Load event on this page is used to obtain // from a database a collection of all products whose // description or name meets a specified search criteria. // // Note that the search string to use is specified using // a querystring argument to the page. // //******************************************************* private void Page_Load(object sender, System.EventArgs e) { // Search database using the supplied "txtSearch" parameter AWC.BusinessLayer.Products productCatalogue = new AWC.BusinessLayer.Products(); MyList.DataSource = productCatalogue.SearchProductDescriptions(Request.Params["txtSearch"]); MyList.DataBind(); // Display a message if no results are found if (MyList.Items.Count == 0) { ErrorMsg.Text = "No items matched your query."; } }
protected void Page_Load(object sender, EventArgs e) { if (Page.IsPostBack != true) { // Obtain ProductID of Product to Review int productID = Int32.Parse(Request["productID"]); // Populate Product Name on Page AWC.BusinessLayer.Products products = new AWC.BusinessLayer.Products(); ModelName.Text = products.GetProductDetails(productID).ModelName; // Store ProductID in Page State to use on PostBack ViewState["productID"] = productID; } }
protected void Page_Load(object sender, EventArgs e) { // Obtain ProductID from QueryString int ProductID = Int32.Parse(Request.Params["ProductID"]); // Obtain Product Details AWC.BusinessLayer.Products products = new AWC.BusinessLayer.Products(); AWC.Entities.Product myProductDetails = products.GetProductDetails(ProductID); // Update Controls with Product Details desc.Text = myProductDetails.Description; UnitCost.Text = String.Format("{0:c}", myProductDetails.UnitCost); ModelName.Text = myProductDetails.ModelName; ModelNumber.Text = myProductDetails.ModelNumber.ToString(); ProductImage.ImageUrl = "ProductImages/" + myProductDetails.ProductImage; addToCart.NavigateUrl = "AddToCart.aspx?ProductID=" + ProductID; ReviewList.ProductID = ProductID; AlsoBoughtList.ProductID = ProductID; }