Esempio n. 1
0
    private void bindProduct()
    {
        if (Request.QueryString["fid"] != null)
        {
            Label1.Text = "Featured";
            dt          = objProduct.GetProductFeatured(0);
        }
        else if (Request.QueryString["pid"] != null)
        {
            Label1.Text = "Popular";
            dt          = objProduct.GetProductPopular(0);
        }
        else if (Request.QueryString["nid"] != null)
        {
            Label1.Text = "New";
            dt          = objProduct.GetProductLatest(0);
        }
        else if (Request.QueryString["sid"] != null)
        {
            Label1.Text = "Search";
            dt          = objProduct.GetProduct(Convert.ToInt32(Request.QueryString["sid"]));
        }
        else if (Request.QueryString["scid"] != null)
        {
            // Label1.Text = Convert.ToString(Request.QueryString["title"]);
            dt = objProduct.GetProductBySubCategoryID(Convert.ToInt32(Request.QueryString["scid"]), true);

            DataTable dt2 = new DataTable();
            dt2                 = objSubCategory.GetSubCategory(Convert.ToInt32(Request.QueryString["scid"]));
            Label1.Text         = Convert.ToString(dt2.Rows[0]["Title"]);
            ltrDescription.Text = Convert.ToString(dt2.Rows[0]["Description"]);
            if (dt2.Rows.Count > 0)
            {
                ((HtmlTitle)Master.FindControl("_metaTitle")).Text = dt2.Rows[0]["MetaTitle"].ToString();
                ((HtmlMeta)Master.FindControl("_metaKeywords")).Attributes.Add("Content", dt2.Rows[0]["MetaKeyword"].ToString());
                ((HtmlMeta)Master.FindControl("_metaDescription")).Attributes.Add("Content", dt2.Rows[0]["MetaDescription"].ToString());
            }
        }
        else if (Request.QueryString["cid"] != null)
        {
            // Label1.Text = Convert.ToString(Request.QueryString["title"]);
            dt = objProduct.GetProductByCategoryID(Convert.ToInt32(Request.QueryString["cid"]));

            DataTable dt2 = new DataTable();
            dt2                 = objCategory.GetCategory(Convert.ToInt32(Request.QueryString["cid"]));
            Label1.Text         = Convert.ToString(dt2.Rows[0]["Title"]);
            ltrDescription.Text = Convert.ToString(dt2.Rows[0]["Description"]);
            if (dt2.Rows.Count > 0)
            {
                ((HtmlTitle)Master.FindControl("_metaTitle")).Text = dt2.Rows[0]["MetaTitle"].ToString();
                ((HtmlMeta)Master.FindControl("_metaKeywords")).Attributes.Add("Content", dt2.Rows[0]["MetaKeyword"].ToString());
                ((HtmlMeta)Master.FindControl("_metaDescription")).Attributes.Add("Content", dt2.Rows[0]["MetaDescription"].ToString());
            }
        }
        else if (Request.QueryString["search"] != null)
        {
            Label1.Text = Convert.ToString(Request.QueryString["search"]);
            dt          = objProduct.GetProductByProductName((Request.QueryString["search"].ToString()));
        }
        else
        {
            Label1.Text = "Popular";
            dt          = objProduct.GetProductPopular(0);
        }


        if (dt.Rows.Count > 0)
        {
            _PagedDataSource.DataSource  = dt.DefaultView;
            _PagedDataSource.AllowPaging = true;
            _PagedDataSource.PageSize    = 8;
            if (currentPage >= 0)
            {
                _PagedDataSource.CurrentPageIndex = currentPage;
                ViewState["TotalPages"]           = _PagedDataSource.PageCount;
                this.btn_first.Enabled            = !_PagedDataSource.IsFirstPage;
                this.btn_last.Enabled             = !_PagedDataSource.IsFirstPage;
                this.btn_next.Enabled             = !_PagedDataSource.IsLastPage;
                this.btn_last.Enabled             = !_PagedDataSource.IsLastPage;

                repProducts.DataSource = _PagedDataSource;
                repProducts.DataBind();
                this.doPaging();
            }
        }
    }