Пример #1
0
        public override void DataBind()
        {
            base.DataBind();

            RelatedProductsRepeater.DataSource = GetRelatedContent();
            RelatedProductsRepeater.DataBind();
        }
        private void LoadData()
        {
            ProductAdapter productAdapter = new ProductAdapter();

            RelatedProductsRepeater.DataSource = productAdapter.GetRelatedProducts(ProductId);
            RelatedProductsRepeater.DataBind();
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (Request.QueryString["id"] != null)
         {
             int       id = Convert.ToInt32(Request.QueryString["id"]);
             DataTable dt = BL.getSingleProduct(id);
             ProductImg.Src                     = $"../AdminDashboard/dist/images/products/{dt.Rows[0]["Image"].ToString()}";
             ProductName.InnerText              = dt.Rows[0]["Name"].ToString();
             CategoryName.InnerText             = dt.Rows[0]["CatName"].ToString();
             Price.InnerText                    = dt.Rows[0]["Price"].ToString();
             ProductDesc.InnerText              = dt.Rows[0]["Description"].ToString();
             RelatedProductsRepeater.DataSource = BL.getRelatedProduct(Convert.ToInt32(dt.Rows[0]["CategoryId"].ToString()), id);
             RelatedProductsRepeater.DataBind();
         }
         else
         {
             Response.Redirect("Index.aspx");
         }
     }
 }
Пример #4
0
    /// <summary>
    /// Raises the <see cref="E:System.Web.UI.Control.DataBinding"/> event.
    /// </summary>
    /// <param name="e">An <see cref="T:System.EventArgs"/> object that contains the event data.</param>
    protected override void OnDataBinding(EventArgs e)
    {
        base.OnDataBinding(e);

        if (Entry != null)
        {
            BindInventory();
            BindPricing();

            Association[] assocs = Entry.Associations;

            if (assocs != null)
            {
                bool relatedProductsMatched   = false;
                bool additionalOptionsMatched = false;

                foreach (Association assoc in assocs)
                {
                    // If there is more than one association name match, the last one wins.
                    // We should prevent this in the CMS.

                    // Check for related products association name matches.
                    if (assoc.Name == RelatedProductsAssociationName)
                    {
                        if (assoc.EntryAssociations != null && assoc.EntryAssociations.Association != null)
                        {
                            RelatedProductsRepeater.DataSource = assoc.EntryAssociations.Association;
                            RelatedProductsRepeater.DataBind();

                            relatedProductsMatched = true;
                            //break;
                        }
                    }

                    // Check for additional options association name matches.
                    if (assoc.Name == AdditionalOptionsAssociationName)
                    {
                        if (assoc.EntryAssociations != null && assoc.EntryAssociations.Association != null)
                        {
                            AdditionalOptionsRepeater.DataSource = assoc.EntryAssociations.Association;
                            AdditionalOptionsRepeater.DataBind();

                            additionalOptionsMatched = true;
                            //break;
                        }
                    }

                    // Set related products panel visibility.
                    this.RelatedProductsPanel.Visible = relatedProductsMatched;

                    // Set additional options panel visibility.
                    this.AdditionalOptionsPanel.Visible = additionalOptionsMatched;
                }
            }
            else
            {
                this.RelatedProductsPanel.Visible   = false;
                this.AdditionalOptionsPanel.Visible = false;
            }
        }
        else
        {
            this.RelatedProductsPanel.Visible   = false;
            this.AdditionalOptionsPanel.Visible = false;
        }
    }