Esempio n. 1
0
        public void LoadDDL()
        {
            Brands_BAL     Bnds   = new Brands_BAL();
            Categories_BAL cate   = new Categories_BAL();
            DataSet        ds     = Bnds.GetAllBrand();
            DataSet        dsCate = cate.GetAllCategories();

            if (ds.Tables[0].Rows.Count > 0)
            {
                //Dispose the Dataset first.
                ds.Dispose();
                DDLBrand.Items.Clear();
                DDLBrand.DataSource     = ds;
                DDLBrand.DataTextField  = "BrandName";
                DDLBrand.DataValueField = "BrandID";
                DDLBrand.DataBind();
                DDLBrand.Items.Insert(0, new ListItem("-- Select any brand --", "0"));
            }
            if (dsCate.Tables[0].Rows.Count > 0)
            {
                //Dispose the Dataset first.
                ds.Dispose();
                DDLCategory.Items.Clear();
                DDLCategory.DataSource     = dsCate;
                DDLCategory.DataTextField  = "CategoryName";
                DDLCategory.DataValueField = "CategoryID";
                DDLCategory.DataBind();
                DDLCategory.Items.Insert(0, new ListItem("-- Select any category --", "0"));
            }
        }
Esempio n. 2
0
    //绑定品牌
    public void BindBrand(int categoryId)
    {
        DDLBrand.Items.Clear();

        DDLBrand.DataSource     = ProductService.BrandsService.GetCategoryBrands(categoryId);
        DDLBrand.DataTextField  = "BrandName";
        DDLBrand.DataValueField = "ID";
        DDLBrand.DataBind();

        ListItem li = new ListItem();

        li.Text  = "==请选择==";
        li.Value = "";
        DDLBrand.Items.Insert(0, li);
    }