当前位置: 首页>>代码示例>>C#>>正文


C# ListItemCollection.FindByText方法代码示例

本文整理汇总了C#中System.Web.UI.WebControls.ListItemCollection.FindByText方法的典型用法代码示例。如果您正苦于以下问题:C# ListItemCollection.FindByText方法的具体用法?C# ListItemCollection.FindByText怎么用?C# ListItemCollection.FindByText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.UI.WebControls.ListItemCollection的用法示例。


在下文中一共展示了ListItemCollection.FindByText方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Methods

		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");
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:40,代码来源:ListItemCollectionTest.cs

示例2: AssignmentTest

		public void AssignmentTest () {
			ListItemCollection	c;
			ListItem		i;

			c = new ListItemCollection();
			i = new ListItem("Text", "Value");

			c.Add(i);

			i = new ListItem("Blah", "Argl");
			((IList)c)[0] = i;

			Assert.AreEqual("Blah", c.FindByText("Blah").ToString(), "AS1");
			Assert.AreEqual(1, c.Count, "AS2");
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:15,代码来源:ListItemCollectionTest.cs

示例3: ViewState

		public void ViewState () {
			ListItemCollection	c;
			ListItemCollection	c2;
			ListItem		i;
			ListItem		i2;
			object			state;

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

			((IStateManager)c).TrackViewState();

			c.Add(i);
			c.Add(i2);
			Assert.AreEqual (2, c.Count, "V1");

			state = ((IStateManager)c).SaveViewState();

			c2 = new ListItemCollection();
			((IStateManager)c2).LoadViewState(state);
			Assert.AreEqual (2, c2.Count, "V2");
			Assert.AreEqual ("Item 1", c2.FindByText("Item 1").ToString(), "V3");
			Assert.AreEqual ("Item 2", c2.FindByText("Item 2").ToString(), "V4");
			Assert.AreEqual (false, c2.IndexOf(i) == c2.IndexOf(i2), "V5");
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:26,代码来源:ListItemCollectionTest.cs

示例4: AddTest

		public void AddTest () 
		{
			ListItemCollection	c;
			ListItem		i;

			c = new ListItemCollection();

			c.Add("string");

			Assert.AreEqual("string", c.FindByText("string").ToString(), "A1");

			c.Add((string)null);
			c.Add((ListItem)null);
			Assert.AreEqual(3, c.Count, "A2");
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:15,代码来源:ListItemCollectionTest.cs


注:本文中的System.Web.UI.WebControls.ListItemCollection.FindByText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。