Esempio n. 1
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (!this.Page.IsPostBack)
            {
                this.cboxCategory.DataSource     = CategoryBrowser.GetAllCategories();
                this.cboxCategory.DataTextField  = "Name";
                this.cboxCategory.DataValueField = "CategoryId";
                this.cboxCategory.DataBind();

                this.cboxBrand.DataSource     = CategoryBrowser.GetBrandCategories();
                this.cboxBrand.DataTextField  = "BrandName";
                this.cboxBrand.DataValueField = "BrandId";
                this.cboxBrand.DataBind();

                this.cboxType.DataSource     = ProductTypeHelper.GetProductTypes();
                this.cboxType.DataTextField  = "TypeName";
                this.cboxType.DataValueField = "TypeId";
                this.cboxType.DataBind();

                DataTable dtData = DistributorsBrower.GetDistributorProductRangeByUserid(int.Parse(Request.QueryString["UserID"]));
                if (dtData.Rows.Count > 0)
                {
                    string strs = string.Empty;
                    if (dtData.Rows[0]["ProductRange1"] != DBNull.Value)
                    {
                        strs = "," + dtData.Rows[0]["ProductRange1"].ToString().Trim() + ",";
                        foreach (ListItem li in this.cboxCategory.Items)
                        {
                            if (strs.IndexOf(li.Value) > -1)
                            {
                                li.Selected = true;
                            }
                        }
                    }
                    if (dtData.Rows[0]["ProductRange2"] != DBNull.Value)
                    {
                        strs = "," + dtData.Rows[0]["ProductRange2"].ToString().Trim() + ",";
                        foreach (ListItem li in this.cboxBrand.Items)
                        {
                            if (strs.IndexOf(li.Value) > -1)
                            {
                                li.Selected = true;
                            }
                        }
                    }
                    if (dtData.Rows[0]["ProductRange3"] != DBNull.Value)
                    {
                        strs = "," + dtData.Rows[0]["ProductRange3"].ToString().Trim() + ",";
                        foreach (ListItem li in this.cboxType.Items)
                        {
                            if (strs.IndexOf(li.Value) > -1)
                            {
                                li.Selected = true;
                            }
                        }
                    }
                }
                ViewState["dtData"] = dtData;
            }
        }
Esempio n. 2
0
        private void getCategories(System.Web.HttpContext context)
        {
            DataTable dtCategory    = CategoryBrowser.GetAllCategories();
            int       categoryCount = ProductBrowser.GetDataCount(" Hishop_Categories ", "");
            //输出JSON
            string result = string.Format("{{\"state\":{0},\r\"count\":{1},\r\"data\":"
                                          , (dtCategory.Rows.Count > 0) ? 0 : 1, categoryCount);

            result += JsonConvert.SerializeObject(dtCategory, Newtonsoft.Json.Formatting.Indented);
            result += "}";
            context.Response.Write(result);
        }
        private void BindCategoryID()
        {
            DataTable allCategories = CategoryBrowser.GetAllCategories(this.wid);

            this.ddlCategoryId.DataTextField  = "Name";
            this.ddlCategoryId.DataValueField = "CategoryId";
            this.ddlCategoryId.DataSource     = allCategories;
            this.ddlCategoryId.DataBind();
            ListItem item = new ListItem("--全部--", "0");

            this.ddlCategoryId.Items.Insert(0, item);
        }