Example #1
0
        private void BindDictionaryList(List<ITreeNode> parents, bool isEmpty)
        {
            using (DictionaryProvider provider = new DictionaryProvider())
            {
                //--- dictionary property -----
                Product product = provider.Products.SingleOrDefault(p => p.ID == this.RequestProductID);
                if (product == null) this.RedirectToErrorPage();

                List<DictionaryTree> list = provider.GetDictionaryTreeList(Guid.Empty, this.Roles);
                var q = from l in list.Where(f => f.ClassificationID.HasValue)
                        join m in parents on l.ClassificationID.Value equals m.ID
                        select new Pair<DictionaryTree, string>(l, m.Name);

                List<DictionaryDDLSource> source = new List<DictionaryDDLSource>();
                foreach (Pair<DictionaryTree, string> item in q.ToList())
                {
                    DictionaryDDLSource entity = new DictionaryDDLSource();
                    entity.DictionaryTreeID = item.First.ID;
                    //set dictionary property title
                    entity.Title = string.Format("{0} ({1})", item.First.Name, item.Second);
                    //get product dicitonary value
                    object value = provider.GetProductDicitonaryValue(this.RequestProductID, item.First.FK);

                    if (value != null && !string.IsNullOrEmpty(value.ToString()) && !isEmpty)
                    {
                        entity.ID = new Guid(value.ToString());//entity.SelectedValue = value.ToString();
                        string valueText = provider.GetProductDictionaryText(entity.ID, item.First).ToString();
                        if (!string.IsNullOrEmpty(valueText) && valueText.Trim().Length > 0) entity.ValueText = valueText;
                    }

                    source.Add(entity);
                }
                DictionaryPropertyRepeater.DataSource = source;
                DictionaryPropertyRepeater.DataBind();
            }
        }