Ejemplo n.º 1
0
		public void Constructor_Null ()
		{
			DataListItemCollection dlic = new DataListItemCollection (null);
			Assert.IsNotNull (dlic, "ctor");
			Assert.IsFalse (dlic.IsReadOnly, "IsReadOnly");
			Assert.IsFalse (dlic.IsSynchronized, "IsSynchronized");
			Assert.IsTrue (Object.ReferenceEquals (dlic, dlic.SyncRoot), "SyncRoot");
			// unusable
			Assert.AreEqual (0, dlic.Count, "NRE");
		}
Ejemplo n.º 2
0
		public void Constructor_WrongType ()
		{
			ArrayList al = new ArrayList ();
			al.Add (String.Empty);
			// DataListItemCollection only deals with DataListItem so...

			DataListItemCollection dlic = new DataListItemCollection (al);
			Assert.AreEqual (1, dlic.Count, "Count0");

			// ... it chokes when accessing the string
			Assert.AreEqual (String.Empty, dlic[0], "[0]");
		}
Ejemplo n.º 3
0
		public void Constructor_Empty ()
		{
			ArrayList al = new ArrayList ();
			DataListItemCollection dlic = new DataListItemCollection (al);
			Assert.AreEqual (0, dlic.Count, "Count0");
			Assert.IsFalse (dlic.IsReadOnly, "IsReadOnly");
			Assert.IsFalse (dlic.IsSynchronized, "IsSynchronized");
			Assert.IsTrue (Object.ReferenceEquals (dlic, dlic.SyncRoot), "SyncRoot");

			al.Add (new DataListItem (0, ListItemType.Item));
			Assert.AreEqual (1, dlic.Count, "Count++");
			// note: no add/insert/remove/...
			Assert.IsNotNull (dlic[0], "[0]");

			al.Clear ();
			Assert.AreEqual (0, dlic.Count, "Count--");
			// we can add/remove from the original ArrayList
		}
Ejemplo n.º 4
0
        /// <summary>
        /// private 方法,根据页面中选中的CheckBox项生成薪酬项id列表
        /// </summary>
        /// <param name="itemCollection"></param>
        /// <param name="chkBoxID"></param>
        /// <param name="hiddenFieldID"></param>
        /// <returns></returns>
        private List<string> GetSelectedSalaryItemIdList(DataListItemCollection itemCollection, string chkBoxID, string hiddenFieldID)
        {
            List<string> itemList = new List<string>();
            foreach (DataListItem item in itemCollection)
            {

                CheckBox chkBox = (CheckBox)item.FindControl(chkBoxID);
                if (chkBox.Checked)
                {
                    string itemId = ((HiddenField)item.FindControl(hiddenFieldID)).Value.Trim();
                    itemList.Add(itemId);
                }
            }
            return itemList;
        }