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

            string search = "";

            int    _categoryId = -1;
            object obj         = DataBinder.Eval(this.NamingContainer, "DataItem.CategoryId");

            if (obj != null)
            {
                _categoryId = (int)obj;
            }

            DataTable itemsView;

            if (Cond != "")
            {
                search += " And " + Cond;
            }

            search += string.Format(" and Status&{0}<>0", (int)ItemStatus.Enabled);

            if (_categoryId != -1)
            {
                search += string.Format(" And CategoryId={0}", _categoryId);
            }

            itemsView = pMgr.GetItemsView(search.Substring(5));

            this.DataSource = itemsView;


            this.Visible = itemsView.Rows.Count > 0;


            base.DataBind();
        }
Ejemplo n.º 2
0
        public object ItemsSrc(Control ctrl, string cond)
        {
            string search = "";

            int _categoryId = -1;

            try
            {
                object obj = DataBinder.Eval(ctrl.NamingContainer, "DataItem.CategoryId");
                if (obj != null)
                {
                    _categoryId = (int)obj;
                }
            }
            catch
            {
            }

            DataTable itemsView;

            if (cond != "")
            {
                search += " And " + cond;
            }
            if (_categoryId != -1)
            {
                search   += string.Format(" And CategoryId={0}", _categoryId);
                itemsView = _itemsMgr.GetItemsView(search.Substring(5));
            }
            else
            {
                itemsView = _itemsMgr.GetItems(search.Substring(5));
            }

            return(itemsView);
        }