public Structures.SelectionItem InsertNewItem(Int32 index)
        {
            Structures.SelectionItem item = new Structures.SelectionItem();

            String itemPrefix = "Item";

            Int32 itemSuffix = 1;


            if (index == -1)
            {
                index = items.Count;
            }

            while (ItemExists(itemPrefix + itemSuffix.ToString()))
            {
                itemSuffix = itemSuffix + 1;
            }

            item.SelectionControl = this;

            item.Text = itemPrefix + itemSuffix.ToString();

            item.Value = itemPrefix + itemSuffix.ToString();

            item.Enabled = true;

            item.Selected = false;

            items.Insert(index, item);

            return(item);
        }
        public void SetItemSelection(String value, String text, Boolean isSelected)
        {
            if ((selectionType == Server.Application.FormControlSelectionType.DropDownList) &&
                (DataSource == Server.Application.FormControlDataSource.Reference))
            {
                items.Clear();

                Structures.SelectionItem selectionItem = InsertNewItem(0);

                selectionItem.Enabled = true;

                selectionItem.Selected = true;

                selectionItem.Text = text;

                selectionItem.Value = value;

                //RaiseEvent ("SelectionChanged");

                //DataSourceChanged ();
            }

            else
            {
                if (ItemExists(value))
                {
                    foreach (Structures.SelectionItem currentItem in items)
                    {
                        if (currentItem.Value == value)
                        {
                            currentItem.Selected = isSelected;
                        }

                        else if ((isSelected) && (selectionMode == Server.Application.FormControlSelectionMode.Single))
                        {
                            currentItem.Selected = false;
                        }
                    }

                    customText = String.Empty;

                    //RaiseEvent ("SelectionChanged");

                    //DataSourceChanged ();
                }

                else if (AllowCustomText)
                {
                    CustomText = text;
                }
            }

            return;
        }
示例#3
0
        public void SetItemSelection(String value, Boolean isSelected)
        {
            Structures.SelectionItem item = Item(value);

            if (item != null)
            {
                SetItemSelection(value, item.Text, isSelected);
            }

            else
            {
                SetItemSelection(value, String.Empty, isSelected);
            }

            return;
        }
        public Boolean ItemSelected(String value)
        {
            Boolean itemSelected = false;

            for (Int32 currentItemIndex = 0; currentItemIndex < items.Count; currentItemIndex++)
            {
                Structures.SelectionItem currentitem = (Structures.SelectionItem)items[currentItemIndex];

                if (currentitem.Value == value)
                {
                    itemSelected = currentitem.Selected;

                    break;
                }
            }

            return(itemSelected);
        }
        public Structures.SelectionItem Item(String value)
        {
            Structures.SelectionItem item = null;

            for (Int32 currentItemIndex = 0; currentItemIndex < items.Count; currentItemIndex++)
            {
                Structures.SelectionItem currentItem = (Structures.SelectionItem)items[currentItemIndex];

                if (currentItem.Value == value)
                {
                    item = currentItem;

                    break;
                }
            }

            return(item);
        }
示例#6
0
        public void SetItemSelection(String value, String text, Boolean isSelected)
        {
            Boolean selectionChanged = false;

            if ((selectionType == Enumerations.FormControlSelectionType.DropDownList) &&

                (DataSource == Enumerations.FormControlDataSource.Reference))
            {
                items.Clear();

                Structures.SelectionItem selectionItem = InsertNewItem(0);

                selectionItem.SelectionControl = this;

                selectionItem.Enabled = true;

                selectionItem.Selected = true;

                selectionItem.Text = text;

                selectionItem.Value = value;

                selectionChanged = true;
            }

            else
            {
                if ((String.IsNullOrEmpty(value)) && (!Required))
                {
                    foreach (Structures.SelectionItem currentItem in items)
                    {
                        currentItem.Selected = false;
                    }
                }

                if (ItemExists(value))
                {
                    foreach (Structures.SelectionItem currentItem in items)
                    {
                        if (currentItem.Value == value)
                        {
                            currentItem.Selected = isSelected;
                        }

                        else if ((isSelected) && (selectionMode == Enumerations.FormControlSelectionMode.Single))
                        {
                            currentItem.Selected = false;
                        }
                    }

                    customText = String.Empty;

                    selectionChanged = true;
                }

                else if (AllowCustomText)
                {
                    if (CustomText != text)
                    {
                        CustomText = text;

                        selectionChanged = true;
                    }
                }
            }

            if (selectionChanged)
            {
                ValueChanged();
            }

            return;
        }