protected void BindData()
        {
            StringBuilder allowedTokensString = new StringBuilder();

            string[] allowedTokens = Pricelist.GetListOfAllowedTokens();
            for (int i = 0; i < allowedTokens.Length; i++)
            {
                string token = allowedTokens[i];
                allowedTokensString.Append(token);
                if (i != allowedTokens.Length - 1)
                {
                    allowedTokensString.Append(", ");
                }
            }
            this.lblAllowedTokens.Text = allowedTokensString.ToString();

            Pricelist pricelist = ProductManager.GetPricelistByID(this.PricelistID);

            if (pricelist != null)
            {
                this.txtAdminNotes.Text    = pricelist.AdminNotes;
                this.txtBody.Text          = pricelist.Body;
                this.txtCacheTime.Value    = pricelist.CacheTime;
                this.txtDescription.Text   = pricelist.Description;
                this.txtDisplayName.Text   = pricelist.DisplayName;
                this.txtFooter.Text        = pricelist.Footer;
                this.txtHeader.Text        = pricelist.Header;
                this.txtPricelistGuid.Text = pricelist.PricelistGuid;
                this.txtShortName.Text     = pricelist.ShortName;
                CommonHelper.SelectListItem(this.ddlExportMode, pricelist.ExportModeID);
                CommonHelper.SelectListItem(this.ddlExportType, pricelist.ExportTypeID);
                CommonHelper.SelectListItem(this.ddlPriceAdjustmentType, pricelist.PriceAdjustmentTypeID);
                CommonHelper.SelectListItem(this.ddlAffiliate, pricelist.AffiliateID);
                this.chkOverrideIndivAdjustment.Checked  = pricelist.OverrideIndivAdjustment;
                this.txtPriceAdjustment.Value            = pricelist.PriceAdjustment;
                this.ddlFormatLocalization.SelectedValue = pricelist.FormatLocalization;

                ProductVariantCollection productVariants = new ProductVariantCollection();
                ProductCollection        products        = ProductManager.GetAllProducts();
                foreach (Product product in products)
                {
                    productVariants.AddRange(product.ProductVariants);
                }
                if (productVariants.Count > 0)
                {
                    gvProductVariants.DataSource = productVariants;
                    gvProductVariants.DataBind();
                }
            }
            else
            {
                ddlFormatLocalization.SelectedValue = System.Globalization.CultureInfo.CurrentCulture.IetfLanguageTag;

                ProductVariantCollection productVariants = new ProductVariantCollection();
                ProductCollection        products        = ProductManager.GetAllProducts();
                foreach (Product product in products)
                {
                    productVariants.AddRange(product.ProductVariants);
                }
                if (productVariants.Count > 0)
                {
                    gvProductVariants.DataSource = productVariants;
                    gvProductVariants.DataBind();
                }
            }
        }
        private string createPricelistContents()
        {
            string strContents = "";

            ProductVariantCollection productVariants = new ProductVariantCollection();
            bool blnOverrideAdjustment = this.OverrideIndivAdjustment;

            switch (this.ExportMode)
            {
            case PriceListExportModeEnum.All:
            {
                blnOverrideAdjustment = true;
                foreach (Product product in ProductManager.GetAllProducts(false))
                {
                    productVariants.AddRange(ProductManager.GetProductVariantsByProductID(product.ProductID, false));
                }
            }
            break;

            case PriceListExportModeEnum.AssignedProducts:
            {
                productVariants = ProductManager.GetProductVariantsByPricelistID(this.PricelistID);
            }
            break;

            default:
                break;
            }

            // create new file
            // write header, if provided
            if (!String.IsNullOrEmpty(this.Header))
            {
                strContents += this.Header;
                if (!this.Header.EndsWith("\n"))
                {
                    strContents += "\n";
                }
            }

            // write body
            foreach (ProductVariant productVariant in productVariants)
            {
                // calculate price adjustments
                decimal newPrice = decimal.Zero;

                // if export mode is all, then calculate price
                if (blnOverrideAdjustment)
                {
                    newPrice = getAdjustedPrice(productVariant.Price, this.PriceAdjustmentType, PriceAdjustment);
                }
                else
                {
                    ProductVariantPricelist productVariantPricelist = ProductManager.GetProductVariantPricelist(productVariant.ProductVariantID, this.PricelistID);
                    if (productVariantPricelist != null)
                    {
                        newPrice = getAdjustedPrice(productVariant.Price, productVariantPricelist.PriceAdjustmentType, productVariantPricelist.PriceAdjustment);
                    }
                }
                strContents += replaceMessageTemplateTokens(productVariant, this.Body,
                                                            this.FormatLocalization, new System.Collections.Specialized.NameValueCollection(), AffiliateID, newPrice);
                if (!this.Body.EndsWith("\n"))
                {
                    strContents += "\n";
                }
            }

            // write footer, if provided
            if (!String.IsNullOrEmpty(this.Footer))
            {
                strContents += this.Header;
                if (!this.Footer.EndsWith("\n"))
                {
                    strContents += "\n";
                }
            }

            return(strContents);
        }
        protected void BindData()
        {
            StringBuilder allowedTokensString = new StringBuilder();
            string[] allowedTokens = Pricelist.GetListOfAllowedTokens();
            for (int i = 0; i < allowedTokens.Length; i++)
            {
                string token = allowedTokens[i];
                allowedTokensString.Append(token);
                if (i != allowedTokens.Length - 1)
                    allowedTokensString.Append(", ");
            }
            this.lblAllowedTokens.Text = allowedTokensString.ToString();

            Pricelist pricelist = ProductManager.GetPricelistByID(this.PricelistID);
            if (pricelist != null)
            {
                this.txtAdminNotes.Text = pricelist.AdminNotes;
                this.txtBody.Text = pricelist.Body;
                this.txtCacheTime.Value = pricelist.CacheTime;
                this.txtDescription.Text = pricelist.Description;
                this.txtDisplayName.Text = pricelist.DisplayName;
                this.txtFooter.Text = pricelist.Footer;
                this.txtHeader.Text = pricelist.Header;
                this.txtPricelistGuid.Text = pricelist.PricelistGuid;
                this.txtShortName.Text = pricelist.ShortName;
                CommonHelper.SelectListItem(this.ddlExportMode, pricelist.ExportModeID);
                CommonHelper.SelectListItem(this.ddlExportType, pricelist.ExportTypeID);
                CommonHelper.SelectListItem(this.ddlPriceAdjustmentType, pricelist.PriceAdjustmentTypeID);
                CommonHelper.SelectListItem(this.ddlAffiliate, pricelist.AffiliateID);
                this.chkOverrideIndivAdjustment.Checked = pricelist.OverrideIndivAdjustment;
                this.txtPriceAdjustment.Value = pricelist.PriceAdjustment;
                this.ddlFormatLocalization.SelectedValue = pricelist.FormatLocalization;

                ProductVariantCollection productVariants = new ProductVariantCollection();
                ProductCollection products = ProductManager.GetAllProducts();
                foreach (Product product in products)
                {
                    productVariants.AddRange(product.ProductVariants);
                }
                if (productVariants.Count > 0)
                {
                    gvProductVariants.DataSource = productVariants;
                    gvProductVariants.DataBind();
                }
            }
            else
            {
                ddlFormatLocalization.SelectedValue = System.Globalization.CultureInfo.CurrentCulture.IetfLanguageTag;

                ProductVariantCollection productVariants = new ProductVariantCollection();
                ProductCollection products = ProductManager.GetAllProducts();
                foreach (Product product in products)
                {
                    productVariants.AddRange(product.ProductVariants);
                }
                if (productVariants.Count > 0)
                {
                    gvProductVariants.DataSource = productVariants;
                    gvProductVariants.DataBind();
                }
            }
        }