예제 #1
0
        //*******************************************************
        //
        // The Page_Load event on this page is used to obtain
        // from a database a collection of all products within a
        // specified product category.  The collection is then
        // databound to a templated asp:datalist control.
        //
        // The product category to obtain is specified using
        // a querystring argument to the page.
        //
        // Note that this page is output cached at 1 hour
        // intervals.  This eliminates the need to hit the database
        // on each request to the page.
        //
        //*******************************************************

        private void Page_Load(object sender, System.EventArgs e)
        {
            // Obtain categoryId from QueryString
            int categoryId = Int32.Parse(Request.Params["CategoryID"]);

            // Obtain products and databind to an asp:datalist control
            IBuySpy.ProductsDB productCatalogue = new IBuySpy.ProductsDB();

            MyList.DataSource = productCatalogue.GetProducts(categoryId);
            MyList.DataBind();
        }
예제 #2
0
        //*******************************************************
        //
        // The Page_Load event on this page is used to obtain
        // from a database a collection of other products
        // that customers who purchased a product "also bought".
        //
        //*******************************************************
        private void Page_Load(object sender, System.EventArgs e)
        {
            // Obtain list of products that people who "also bought" an item have purchased.  Databind to list control
            IBuySpy.ProductsDB productCatalogue = new IBuySpy.ProductsDB();

            alsoBoughtList.DataSource = productCatalogue.GetProductsAlsoPurchased(ProductID);
            alsoBoughtList.DataBind();

            // Hide the list if no items are in it
            if (alsoBoughtList.Items.Count == 0)
            {
                alsoBoughtList.Visible = false;
            }
        }
예제 #3
0
        //*******************************************************
        //
        // 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
            IBuySpy.ProductsDB productCatalogue = new IBuySpy.ProductsDB();

            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.";
            }
        }
예제 #4
0
        //*******************************************************
        //
        // The Page_Load event on this page is used to obtain
        // from a database a list of all popular items this
        // weel and then databind it to an asp:datalist control.
        //
        // To optimize performance, this user control is output
        // cached for a period of 1 hour.
        //
        //*******************************************************
        private void Page_Load(object sender, System.EventArgs e)
        {
            // Obtain list of favorite items
            IBuySpy.ProductsDB products = new IBuySpy.ProductsDB();

            // Databind and display the list of favorite product items
            productList.DataSource = products.GetMostPopularProductsOfWeek();
            productList.DataBind();

            // Hide the list if no items are in it
            if (productList.Items.Count == 0)
            {
                productList.Visible = false;
            }
        }
예제 #5
0
        //*******************************************************
        //
        // The Page_Load event on this page is used to fetch details
        // about the product to review.  It then updates UI elements
        // with the results.
        //
        // Note that the product to review is specified using
        // a querystring argument to the page.
        //
        //*******************************************************

        private void Page_Load(object sender, System.EventArgs e)
        {
            if (Page.IsPostBack != true)
            {
                // Obtain ProductID of Product to Review
                int productID = Int32.Parse(Request["productID"]);

                // Populate Product Name on Page
                IBuySpy.ProductsDB products = new IBuySpy.ProductsDB();
                ModelName.Text = products.GetProductDetails(productID).ModelName;

                // Store ProductID in Page State to use on PostBack
                ViewState["productID"] = productID;
            }
        }
예제 #6
0
        //*******************************************************
        //
        // The Page_Load event on this page is used to obtain
        // from a database a list of all product categories
        // and databind it to an asp:datalist control.
        //
        // To optimize performance, this user control is output
        // cached (varying based on the categoryId and selection
        // passed through the querystring.
        //
        //*******************************************************

        private void Page_Load(object sender, System.EventArgs e)
        {
            // Set the curent selection of list
            String selectionId = Request.Params["selection"];

            if (selectionId != null)
            {
                MyList.SelectedIndex = Int32.Parse(selectionId);
            }

            // Obtain list of menu categories and databind to list control
            IBuySpy.ProductsDB products = new IBuySpy.ProductsDB();

            MyList.DataSource = products.GetProductCategories();
            MyList.DataBind();
        }
예제 #7
0
        //*******************************************************
        //
        // The Page_Load event on this page is used to obtain
        // product information from a database and then update
        // UI elements with them.
        //
        // Note that this page is output cached at 1 minute
        // intervals.  This eliminates the need to hit the database
        // on each request to the page.
        //
        //*******************************************************

        private void Page_Load(object sender, System.EventArgs e)
        {
            // Obtain ProductID from QueryString
            int ProductID = Int32.Parse(Request.Params["ProductID"]);

            // Obtain Product Details
            IBuySpy.ProductsDB     products         = new IBuySpy.ProductsDB();
            IBuySpy.ProductDetails 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;
        }