示例#1
0
        //*******************************************************
        //
        // The Page_Load event on this user control is used to obtain
        // from a database a list of reviews about a specified
        // product and then databind it to an asp:datalist control.
        //
        //*******************************************************
        protected void Page_Load(object sender, EventArgs e)
        {
            // Obtain and databind a list of all reviews of a product

            // Obtain ProductID from Page State
            _nav = new CatalogNavigation(Request.QueryString);

            ReviewController controller = new ReviewController();
            lstReviews.DataSource = controller.GetReviewsByProduct(PortalId, _nav.ProductID, ReviewController.StatusFilter.Approved);
            lstReviews.DataBind();
        }
示例#2
0
        private void FillReviewGrid()
        {
            panelList.Visible = true;
            panelEdit.Visible = false;

            grdReviews.DataSource = null;

            // Get the status filter
            ReviewController.StatusFilter filter = ReviewController.StatusFilter.All;
            if (cmbStatus.SelectedValue == "0")
            {
                filter = ReviewController.StatusFilter.NotApproved;
            }
            else if (cmbStatus.SelectedValue == "1")
            {
                filter = ReviewController.StatusFilter.Approved;
            }

            // Get the product list...
            ArrayList reviewList;
            ReviewController controller = new ReviewController();
            if (cmbProduct.SelectedValue != Null.NullInteger.ToString())
            {
                // Select by product
                reviewList = controller.GetReviewsByProduct(this.PortalId, int.Parse(cmbProduct.SelectedValue), filter);
            }
            else if (cmbCategory.SelectedValue != Null.NullInteger.ToString())
            {
                // Select by category
                reviewList = controller.GetReviewsByCategory(this.PortalId, int.Parse(cmbCategory.SelectedValue), filter);
            }
            else
            {
                // Select all reviews
                reviewList = controller.GetReviews(this.PortalId, filter);
            }

            // Has page index been initialized?
            if (_nav.PageIndex == Null.NullInteger)
            {
                _nav.PageIndex = 0;
            }

            // Update the grid
            grdReviews.PageSize = 20;
            grdReviews.AllowPaging = true;
            grdReviews.DataSource = reviewList;
            grdReviews.CurrentPageIndex = _nav.PageIndex;
            grdReviews.DataBind();
        }