本文整理匯總了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, "<", "A7");
Assert.AreEqual (((LiteralControl) item.Controls [0].Controls [1]).Text,
" ", "A7");
Assert.AreEqual (((Label) item.Controls [0].Controls [2]).Text, ">", "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, "<", "A14");
Assert.AreEqual (((LiteralControl) item.Controls [0].Controls [1]).Text,
" ", "A16");
next = (LinkButton) item.Controls [0].Controls [2];
Assert.AreEqual (next.Text, ">", "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,
" ", "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, ">", "A25");
Assert.AreEqual (next.CommandName, "Page", "A26");
Assert.AreEqual (next.CommandArgument, "Next", "A27");
prev = (LinkButton) item.Controls [0].Controls [0];
Assert.AreEqual (prev.Text, "<", "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;
//.........這裏部分代碼省略.........