Пример #1
0
        private void GenerateList()
        {
            string lang   = "@Name";
            string xQuery = String.Format("Lists/List[@Key='{0}']/Item", ListType.ToString());

            string filePath = string.Format(ConfigManager.Current.pathForLists, Util.CurrentUserLang);

            foreach (XmlNode node in CachedDocumentManager.GetXmlNodeList(filePath, xQuery))
            {
                string  v = node.SelectSingleNode("@Value").InnerText;
                string  n;
                XmlNode nameNode = node.SelectSingleNode(lang);
                if (nameNode == null)
                {
                    nameNode = node.SelectSingleNode("@Name");
                }
                n = (nameNode == null) ? "Unknown" : nameNode.InnerText;

                this.Items.Add(new ListItem(n, v));
            }
            if (AddAllItem)
            {
                try
                {
                    this.Items.Insert(0, new ListItem(ResourceManager.GetResource("all"), ""));
                    this.SelectedIndex = 0;
                }
                catch {}
            }
        }
Пример #2
0
        private void GenerateList()
        {
            string lang   = "@Name";
            string xQuery = String.Format("Lists/List[@Key='{0}']/Item", ListType.ToString());

            ListItem liChoose = null;

            SortedList slItems = null;

            if (SortByText == true)
            {
                slItems = new SortedList();
            }

            string filePath = string.Format(ConfigManager.Current.pathForLists, Util.CurrentUserLang);

            foreach (XmlNode node in CachedDocumentManager.GetXmlNodeList(filePath, xQuery))
            {
                string  v = node.SelectSingleNode("@Value").InnerText;
                string  n;
                XmlNode nameNode = node.SelectSingleNode(lang);
                if (nameNode == null)
                {
                    nameNode = node.SelectSingleNode("@Name");
                }
                n = (nameNode == null) ? "Unknown" : nameNode.InnerText;

                if (!(ShowChooseItem == false && (n.StartsWith("Seçiniz") || n.StartsWith("Please select"))))
                {
                    if (SortByText == true)
                    {
                        if (!slItems.ContainsKey(n))
                        {
                            slItems.Add(n, v);
                        }
                    }
                    else
                    {
                        this.Items.Add(new ListItem(n, v));
                    }
                }
            }
            if (SortByText == true)     //Added for Sorting.
            {
                this.DataSource     = slItems;
                this.DataTextField  = "Key";
                this.DataValueField = "Value";
                this.DataBind();

                if (this.ShowChooseItem == true)
                {
                    liChoose = this.Items.FindByText(ResourceManager.GetResource("seciniz"));

                    if (liChoose != null)
                    {
                        this.Items.Remove(liChoose);
                        this.Items.Insert(0, liChoose);
                    }
                }
            }
        }