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


C# DataGridPoker.InitPager方法代码示例

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


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

示例1: InitializePager

		public void InitializePager ()
		{
			DataGridPoker p = new DataGridPoker ();
			PagedDataSource paged = new PagedDataSource ();
			DataTable table = new DataTable ();
			DataGridItem item = new DataGridItem (-1, -1, ListItemType.Pager);
			ArrayList columns;
			LinkButton next;
			LinkButton prev;

			table.Columns.Add (new DataColumn ("one", typeof (string)));
			table.Columns.Add (new DataColumn ("two", typeof (string)));
			table.Columns.Add (new DataColumn ("three", typeof (string)));

			for (int i = 0; i < 25; i++)
				table.Rows.Add (new object [] { "1", "2", "3" });
			paged.DataSource = new DataView (table);

			columns = p.CreateColumns (paged, true);
			p.InitPager (item, columns.Count, paged);

			//
			// No where to go
			//

			Assert.AreEqual (item.Controls.Count, 1, "A1");
			Assert.AreEqual (item.Controls [0].GetType (), typeof (TableCell), "A2");
			Assert.AreEqual (item.Controls [0].Controls.Count, 3, "A3");
			Assert.AreEqual (item.Controls [0].Controls [0].GetType (), typeof (Label), "A4");
			Assert.AreEqual (item.Controls [0].Controls [1].GetType (),
					typeof (LiteralControl), "A5");
			Assert.AreEqual (item.Controls [0].Controls [2].GetType (), typeof (Label), "A6");
			Assert.AreEqual (((Label) item.Controls [0].Controls [0]).Text, "&lt;", "A7");
			Assert.AreEqual (((LiteralControl) item.Controls [0].Controls [1]).Text,
					"&nbsp;", "A7");
			Assert.AreEqual (((Label) item.Controls [0].Controls [2]).Text, "&gt;", "A8");

			//
			// Next
			//

			item = new DataGridItem (-1, -1, ListItemType.Pager);
			paged.PageSize = 5;
			paged.VirtualCount = 25;
			paged.AllowPaging = true;
			p.InitPager (item, columns.Count, paged);

			Assert.AreEqual (item.Controls.Count, 1, "A9");
			Assert.AreEqual (item.Controls [0].GetType (), typeof (TableCell), "A10");
			Assert.AreEqual (item.Controls [0].Controls.Count, 3, "A11");
			Assert.AreEqual (item.Controls [0].Controls [0].GetType (), typeof (Label), "A12");
			Assert.AreEqual (item.Controls [0].Controls [1].GetType (),
					typeof (LiteralControl), "A13");
			Assert.AreEqual (((Label) item.Controls [0].Controls [0]).Text, "&lt;", "A14");
			Assert.AreEqual (((LiteralControl) item.Controls [0].Controls [1]).Text,
					"&nbsp;", "A16");

			next = (LinkButton) item.Controls [0].Controls [2];
			Assert.AreEqual (next.Text, "&gt;", "A17");
			Assert.AreEqual (next.CommandName, "Page", "A18");
			Assert.AreEqual (next.CommandArgument, "Next", "A19");


			//
			// Both
			//

			item = new DataGridItem (-1, -1, ListItemType.Pager);
			paged.PageSize = 5;
			paged.VirtualCount = 25;
			paged.AllowPaging = true;
			paged.CurrentPageIndex = 2;
			p.InitPager (item, columns.Count, paged);

			Assert.AreEqual (item.Controls.Count, 1, "A20");
			Assert.AreEqual (item.Controls [0].GetType (), typeof (TableCell), "A21");
			Assert.AreEqual (item.Controls [0].Controls.Count, 3, "A22");
			Assert.AreEqual (item.Controls [0].Controls [1].GetType (),
					typeof (LiteralControl), "A23");
			Assert.AreEqual (((LiteralControl) item.Controls [0].Controls [1]).Text,
					"&nbsp;", "A24");

			// This is failing with an invalidcast right now. It's something related to
			// the pager thinking that it's on the last page and rendering a label instead
			next = (LinkButton) item.Controls [0].Controls [2];
			Assert.AreEqual (next.Text, "&gt;", "A25");
			Assert.AreEqual (next.CommandName, "Page", "A26");
			Assert.AreEqual (next.CommandArgument, "Next", "A27");

			prev = (LinkButton) item.Controls [0].Controls [0];
			Assert.AreEqual (prev.Text, "&lt;", "A28");
			Assert.AreEqual (prev.CommandName, "Page", "A29");
			Assert.AreEqual (prev.CommandArgument, "Prev", "A30");

			//
			// Back only
			//

			item = new DataGridItem (-1, -1, ListItemType.Pager);
			paged.PageSize = 5;
//.........这里部分代码省略.........
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:101,代码来源:DataGridTest.cs


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