protected void checkedCategories_DataBound(object sender, EventArgs e) { ListItemCollection checkedCats = checkedCategories.Items; CheckBox showInt = ResultsPanel.FindControl("showIntStakeholders") as CheckBox; /* Remove last (special) and the first (general) categories */ if (checkedCats.Count > 6) // check that there is the 'special' category (= 'Other' selected in start) { checkedCats.RemoveAt(6); showInt.Visible = true; } else { showInt.Visible = false; } checkedCats.RemoveAt(0); for (int i = 0; i < checkedCats.Count; i++) { checkedCats[i].Selected = true; checkedCats[i].Attributes.Add("Name", "checkedCategories"); } }
public void RemoveInvalidTest() { 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); c.RemoveAt(20); }
private static ListItemCollection GetSubMenu(Control control, int menuType) { if (Pages.Session(control)["MAINMENU"] == null || Pages.Session(control)["MAINMENUID"] == null) { return(null); } ArrayList item = (ArrayList)Pages.Session(control)["MAINMENUID"]; ListItemCollection listItemCollections = (ListItemCollection)Pages.Session(control)["MAINMENU"]; ListItemCollection listItemCollections1 = new ListItemCollection(); SqlConnection connection = ConnectDB.GetConnection(); SqlCommand sqlCommand = new SqlCommand("admin_AdminSubMenu", connection) { CommandType = CommandType.StoredProcedure }; SqlParameter employeeID = sqlCommand.Parameters.Add("@employeeid", SqlDbType.Int); employeeID.Value = UserAuthorize.GetUserProfile(control).EmployeeID; SqlParameter sqlParameter = sqlCommand.Parameters.Add("@rootid", SqlDbType.Char); sqlParameter.Value = (string)item[menuType]; SqlDataReader sqlDataReaders = sqlCommand.ExecuteReader(); string str = null; while (sqlDataReaders.Read()) { string item1 = (string)sqlDataReaders["adminmenutext"]; string str1 = (string)sqlDataReaders["link"]; if (item1 == "-" && item1 == str) { continue; } if (str1 != "") { str1 = Pages.Url(control, str1); } listItemCollections1.Add(new ListItem(item1, str1)); str = item1; } if (listItemCollections1.Count > 0 && listItemCollections1[listItemCollections1.Count - 1].Text == "-") { listItemCollections1.RemoveAt(listItemCollections1.Count - 1); } sqlDataReaders.Close(); connection.Close(); Pages.Session(control)[string.Concat("SUBMENU", menuType)] = listItemCollections1; return((ListItemCollection)Pages.Session(control)[string.Concat("SUBMENU", menuType)]); }
private void InitialiseControlItems() { ListItemCollection collection = (this.Control as IHaveListItems).Items; for (Int32 i = collection.Count - 1; i >= 0; i--) { CustomisationItem item = (this.Configuration["Items"] as CustomisationItem[]).FirstOrDefault(x => x.Value == collection[i].Value); if (item != null && item.Displayed) { collection[i].Text = item.CustomText.TrimOrNullify() ?? collection[i].Text; } if (item != null && !item.Displayed) { collection.RemoveAt(i); } } }
public static void LoadZones(ListItemCollection lstZones, int userID) { LoadZones(lstZones); string cmsRoles = "|" + RoleDB.GetUserCMSRoles(userID, AppEnv.GetLanguage()); int i = 0; while (i < lstZones.Count) { if (cmsRoles.IndexOf("|" + lstZones[i].Value + "|") < 0) { lstZones.RemoveAt(i); } else { i += 1; } } }
public void Methods() { ListItemCollection c; ListItem i; ListItem i2; c = new ListItemCollection(); Assert.AreEqual(0, c.Count, "T1"); i = new ListItem("Item 1", "10"); c.Add(i); Assert.AreEqual(1, c.Count, "T2"); i = new ListItem("This is item 2", "20"); c.Add(i); Assert.AreEqual(2, c.Count, "T3"); Assert.AreEqual(null, c.FindByText(" is "), "T4"); Assert.AreEqual(i.Text, c.FindByText("This is item 2").Text, "T5"); Assert.AreSame(i, c.FindByText("This is item 2"), "T6"); Assert.AreEqual(1, c.IndexOf(c.FindByText("This is item 2")), "T7"); Assert.AreEqual(1, c.IndexOf(c.FindByValue("20")), "T8"); i = new ListItem("Item 3", "30"); Assert.IsFalse(c.Contains(i), "T9"); c.Add(i); Assert.IsTrue(c.Contains(i), "T10"); i = new ListItem("Forth", "40"); i2 = new ListItem("Fifth", "50"); c.AddRange(new ListItem[] { i, i2 }); Assert.AreEqual(5, c.Count, "T11"); c.RemoveAt(1); Assert.AreEqual(4, c.Count, "T12"); Assert.AreEqual(null, c.FindByText("This is item 2"), "T13"); c.Clear(); Assert.AreEqual(0, c.Count, "T13"); }
protected void MoveSelectedUp(ListItemCollection items) { var selItems = new List<ListItem>(); for (int i = items.Count - 1; i >= 0; i--) { if (items[i].Selected) { selItems.Add(items[i]); items.RemoveAt(i); } } foreach (var i in selItems) items.Insert(0, i); }