Beispiel #1
0
    void LoadParentDrop()
    {
        if (ParentID.Items.Count == 0)
        {
            ListItemCollection items = GetPageHierarchy();
            foreach (ListItem item in items)
            {
                ParentID.Items.Add(item);
            }        //remove this page from the list, since it can't
            //be it's own parent
            foreach (ListItem item in items)
            {
                if (item.Value == thisPage.PageID.ToString())
                {
                    items.Remove(item);
                    break;
                }
            }


            //set the default
            ParentID.Items.Insert(0, new ListItem("--None--", "0"));

            //set the selection
            if (thisPage.ParentID != null)
            {
                ParentID.SelectedValue = thisPage.ParentID.ToString();
            }
            else
            {
                ParentID.SelectedIndex = 0;
            }
        }
    }
Beispiel #2
0
        public static void RemoveByValue(this ListItemCollection items, string value)
        {
            var item = items.FindByValue(value);

            if (item != null)
            {
                items.Remove(item);
            }
        }
Beispiel #3
0
    public void exchangeSelected(ListItemCollection source, ListItemCollection destination, bool selected)
    {
        List <ListItem> list = new List <ListItem>();

        foreach (ListItem item in source)
        {
            if (item.Selected == selected && item.Enabled == true)
            {
                destination.Add(item);
                list.Add(item);
            }
        }
        int c = 0;

        foreach (ListItem item in list)
        {
            source.Remove(list[c++]);
        }
    }
Beispiel #4
0
        public void RemoveTest()
        {
            ListItemCollection c;
            ListItem           i;
            ListItem           i2;

            c  = new ListItemCollection();
            i  = new ListItem("Item 1", "1");
            i2 = new ListItem("Item 2", "2");

            c.Add(i);
            c.Add(i2);

            i = new ListItem("Item 2", "2");

            // test same vs equal
            c.Remove(i);
            Assert.AreEqual(1, c.Count, "R1");
        }
Beispiel #5
0
        private void BindDropDown(int intCategoryNotToShow)
        {
            // Bind drop-down
            CategoriesDropDown colCategoriesDropDown = new CategoriesDropDown(PortalId);
            ListItemCollection objListItemCollection = colCategoriesDropDown.Categories(intCategoryNotToShow);

            // Don't show the currently selected node
            foreach (ListItem objListItem in objListItemCollection)
            {
                if (objListItem.Value == intCategoryNotToShow.ToString())
                {
                    objListItemCollection.Remove(objListItem);
                    break;
                }
            }

            ddlParentCategory.DataSource     = objListItemCollection;
            ddlParentCategory.DataTextField  = "Text";
            ddlParentCategory.DataValueField = "Value";
            ddlParentCategory.DataBind();
        }
Beispiel #6
0
 public static void ItemsChange(ListItemCollection p_來源Items, ListItemCollection p_目地Items, Items移動格式 p_格式, Item移動項目 p_項目)
 {
     for (int i = 0; i < p_來源Items.Count; i++)
     {
         ListItem l_item = p_來源Items[i];
         if (p_項目.Equals(Item移動項目.全部) || (p_項目.Equals(Item移動項目.選取) && l_item.Selected))
         {
             l_item.Selected = false;
             if (p_格式.Equals(Items移動格式.複製))
             {
                 l_item = new ListItem(l_item.Text, l_item.Value);
             }
             else if (p_格式.Equals(Items移動格式.搬移))
             {
                 p_來源Items.Remove(l_item);
                 i--;
             }
             p_目地Items.Add(l_item);
         }
     }
 }
    private void SynList()
    {
        ArrayList          arrayValue     = new ArrayList(TextBoxSynOrder.Text.Split(','));
        ListItemCollection itemCollection = new ListItemCollection();

        itemCollection.AddRange((ListItem[])new ArrayList(ListBoxLeft.Items).ToArray(typeof(ListItem)));
        itemCollection.AddRange((ListItem[])new ArrayList(ListBoxRight.Items).ToArray(typeof(ListItem)));

        ListBoxLeft.Items.Clear();
        ListBoxRight.Items.Clear();
        for (int i = 0; i < arrayValue.Count; i++)
        {
            ListItem item = itemCollection.FindByValue(arrayValue[i].ToString());
            if (item != null)
            {
                ListBoxRight.Items.Add(item);

                itemCollection.Remove(item);
            }
        }
        ListBoxLeft.Items.AddRange((ListItem[])new ArrayList(itemCollection).ToArray(typeof(ListItem)));
    }
Beispiel #8
0
        protected string ProjectWhereString()
        {
            StringBuilder ret = new StringBuilder();

            ListItemCollection items_ = new ListItemCollection();

            foreach (ListItem itm in DDLProject.Items)
            {
                items_.Add(itm);
            }

            items_.Remove(items_.FindByValue("0"));

            for (int i = 0; i < items_.Count; i++)
            {
                ret.Append(string.Format("'{0}'", items_[i].Value));

                if (i < items_.Count - 1)
                {
                    ret.Append(",");
                }
            }
            return(ret.ToString());
        }