コード例 #1
0
        // Product Type Editor
        private void LoadProductTypeEditor(ProductType q)
        {
            List <MerchantTribe.Commerce.Catalog.ProductType> allTypes = MyPage.MTApp.CatalogServices.ProductTypes.FindAll();

            allTypes.Insert(0, new MerchantTribe.Commerce.Catalog.ProductType()
            {
                Bvin = "0", ProductTypeName = "Generic"
            });

            List <FriendlyBvinDisplay> displayData = new List <FriendlyBvinDisplay>();

            foreach (string bvin in q.CurrentTypeIds())
            {
                FriendlyBvinDisplay item = new FriendlyBvinDisplay();
                item.bvin        = bvin;
                item.DisplayName = bvin;

                var t = allTypes.Where(y => y.Bvin == bvin).FirstOrDefault();
                if (t != null)
                {
                    item.DisplayName = t.ProductTypeName;
                    allTypes.Remove(t);
                }
                displayData.Add(item);
            }

            this.lstProductTypes.DataSource     = allTypes;
            this.lstProductTypes.DataValueField = "Bvin";
            this.lstProductTypes.DataTextField  = "ProductTypeName";
            this.lstProductTypes.DataBind();

            this.gvProductTypes.DataSource = displayData;
            this.gvProductTypes.DataBind();
        }