Exemplo n.º 1
0
        public override void DataBind()
        {
            if (this._bound)
            {
                return;
            }
            _bound = true;

            object obj = ControlUtils.GetBoundedDataField(this.NamingContainer, "CategoryId");

            if (!String.IsNullOrEmpty(obj.ToString()))
            {
                _categoryId = Int32.Parse(obj.ToString());
            }
            else
            {
                return;
            }

            CategoriesMgr cMgr = new CategoriesMgr();
            DataRow       cat  = cMgr.GetCategory(_categoryId);

            if (StringUtils.IsNullOrWhiteSpace(cat["Image"]))
            {
                this.Visible = false;
            }
            else
            {
                switch (Type)
                {
                case LinkType.Title:
                    this.InnerHtml = string.Format(Format, cat["Title"]);
                    this.Title     = cat["Title"].ToString();
                    this.HRef      = string.Format("~/{0}/Large/{1}", DestinationFolder, cat["Image"]);
                    break;

                case LinkType.Image:
                default:
                    this.Controls.Add(new CategoryImage(cat["Image"], cat["Title"]));
                    this.Title = cat["Title"].ToString();
                    this.HRef  = string.Format("~/{0}/Large/{1}", DestinationFolder, cat["Image"]);
                    break;
                }
            }

            base.DataBind();
        }
Exemplo n.º 2
0
        public override void DataBind()
        {
            if (bound)
            {
                return;
            }
            bound = true;

            CategoriesMgr pMgr = new CategoriesMgr();

            string cond = "";
            Object obj  = null;

            try
            {
                obj = DataBinder.Eval(this.NamingContainer, "DataItem.CategoryId");
            }
            catch
            {
            }
            if (obj == null)
            {
                if (region != "")
                {
                    DataRow regions = pMgr.GetCategory(StringUtils.SQLEncode(region));
                    if (regions != null)
                    {
                        cond = string.Format("CategoryId={0}", regions["CategoryId"]);
                    }
                }
            }
            else
            {
                cond = string.Format("CategoryId={0}", obj);
            }

            string   sql     = "select * from ItemsView where " + cond;
            DataView schools = DBUtils.GetDataSet(sql, lw.Products.cte.lib).Tables[0].DefaultView;

            schools.Sort    = "Brand, UserRating DESC, Ranking Asc, Title, ProductNumber";
            this.DataSource = schools;

            base.DataBind();
        }