本文整理汇总了C#中MonoTests.System.Web.UI.WebControls.PokerGridView.DataBind方法的典型用法代码示例。如果您正苦于以下问题:C# PokerGridView.DataBind方法的具体用法?C# PokerGridView.DataBind怎么用?C# PokerGridView.DataBind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MonoTests.System.Web.UI.WebControls.PokerGridView
的用法示例。
在下文中一共展示了PokerGridView.DataBind方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GridView_CreateDataSourceSelectArguments
public void GridView_CreateDataSourceSelectArguments ()
{
DataSourceView view;
Page p = new Page ();
PokerGridView g = new PokerGridView ();
g.Sorting += new GridViewSortEventHandler (g_Sorting);
p.Controls.Add (g);
ObjectDataSource data = new ObjectDataSource ();
data.TypeName = typeof (DataSourceObject).AssemblyQualifiedName;
data.SelectMethod = "GetList";
data.SortParameterName = "sortExpression";
DataSourceSelectArguments arg;
p.Controls.Add (data);
g.DataSource = data;
g.DataBind ();
arg = g.DoCreateDataSourceSelectArguments ();
Assert.IsTrue (arg.Equals (DataSourceSelectArguments.Empty), "Default");
g.AllowPaging = true;
g.PageIndex = 2;
g.PageSize = 3;
arg = g.DoCreateDataSourceSelectArguments ();
view = g.DoGetData ();
Assert.IsFalse (view.CanPage);
Assert.IsTrue (view.CanRetrieveTotalRowCount);
Assert.IsTrue (arg.Equals (DataSourceSelectArguments.Empty), "AllowPaging = true, CanPage = false, CanRetrieveTotalRowCount = true");
// make DataSourceView.CanPage = true
data.EnablePaging = true;
arg = g.DoCreateDataSourceSelectArguments ();
view = g.DoGetData ();
Assert.IsTrue (view.CanPage);
Assert.IsFalse (view.CanRetrieveTotalRowCount);
Assert.IsTrue (arg.Equals (new DataSourceSelectArguments (6, -1)), "AllowPaging = true, CanPage = true, CanRetrieveTotalRowCount = false");
g.AllowPaging = false;
arg = g.DoCreateDataSourceSelectArguments ();
Assert.IsTrue (arg.Equals (DataSourceSelectArguments.Empty), "AllowPaging = false, CanPage = true, CanRetrieveTotalRowCount = false");
// make DataSourceView.CanRetrieveTotalRowCount = true
data.SelectCountMethod = "GetCount";
arg = g.DoCreateDataSourceSelectArguments ();
Assert.IsTrue (arg.Equals (DataSourceSelectArguments.Empty), "AllowPaging = false, CanPage = true, CanRetrieveTotalRowCount = true");
g.AllowPaging = true;
arg = g.DoCreateDataSourceSelectArguments ();
DataSourceSelectArguments arg1 = new DataSourceSelectArguments (6, 3);
arg1.RetrieveTotalRowCount = true;
view = g.DoGetData ();
Assert.IsTrue (view.CanPage);
Assert.IsTrue (view.CanRetrieveTotalRowCount);
Assert.IsTrue (arg.Equals (arg1), "AllowPaging = true, CanPage = true, CanRetrieveTotalRowCount = true");
g.AllowPaging = false;
g.AllowSorting = true;
g.EditIndex = 2;
g.PageIndex = 1;
g.Sort ("sort", SortDirection.Descending);
Assert.AreEqual (2, g.EditIndex, "EditIndex after Sort, Bound by DataSource");
Assert.AreEqual (1, g.PageIndex, "PageIndex after Sort, Bound by DataSource");
arg = g.DoCreateDataSourceSelectArguments ();
view = g.DoGetData ();
Assert.IsTrue (view.CanSort);
Assert.AreEqual (String.Empty, g.SortExpression, "SortExpression, Bound by DataSource");
Assert.AreEqual (SortDirection.Ascending, g.SortDirection, "SortDirection, Bound by DataSource");
Assert.IsTrue (arg.Equals (DataSourceSelectArguments.Empty), "AllowSorting = true, Bound by DataSource");
}
示例2: GridView_PageCount
public void GridView_PageCount ()
{
Page p = new Page ();
PokerGridView gv = new PokerGridView ();
gv.PageSize = 3;
gv.AllowPaging = true;
p.Controls.Add (gv);
ObjectDataSource data = new ObjectDataSource ();
data.ID = "ObjectDataSource1";
data.TypeName = typeof (DataSourceObject).AssemblyQualifiedName;
data.SelectMethod = "GetList";
p.Controls.Add (data);
gv.DataSourceID = "ObjectDataSource1";
gv.SetRequiresDataBinding (true);
Assert.AreEqual (0, gv.PageCount, "PageCount before binding");
gv.DataBind ();
Assert.AreEqual (2, gv.PageCount, "PageCount after binding");
PokerGridView copy = new PokerGridView ();
copy.DoLoadControlState (gv.DoSaveControlState ());
Assert.AreEqual (2, copy.PageCount, "PageCount from ViewState");
}
示例3: GridView_DataKeys
public void GridView_DataKeys ()
{
Page p = new Page ();
PokerGridView gv = new PokerGridView ();
p.Controls.Add (gv);
ObjectDataSource data = new ObjectDataSource ();
data.TypeName = typeof (DataObject).AssemblyQualifiedName;
data.SelectMethod = "Select";
p.Controls.Add (data);
gv.DataSource = data;
gv.DataKeyNames = new string [] { "ID", "FName" };
DataKeyArray keys1 = gv.DataKeys;
Assert.AreEqual (0, keys1.Count, "DataKeys count before binding");
gv.DataBind ();
DataKeyArray keys2 = gv.DataKeys;
DataKeyArray keys3 = gv.DataKeys;
Assert.IsFalse (Object.ReferenceEquals (keys1, keys2), "DataKey returns the same instans");
Assert.IsTrue (Object.ReferenceEquals (keys2, keys3), "DataKey returns the same instans");
Assert.AreEqual (1, keys1.Count, "DataKeys count after binding");
Assert.AreEqual (1001, keys1 [0].Value, "DataKey.Value after binding");
Assert.AreEqual (2, keys1 [0].Values.Count, "DataKey.Values count after binding");
Assert.AreEqual (1001, keys1 [0].Values [0], "DataKey.Values[0] after binding");
Assert.AreEqual ("Mahesh", keys1 [0].Values [1], "DataKey.Values[1] after binding");
PokerGridView copy = new PokerGridView ();
object state = gv.DoSaveControlState ();
copy.DoLoadControlState (state);
DataKeyArray keys4 = copy.DataKeys;
Assert.AreEqual (1, keys4.Count, "DataKeys count from ControlState");
Assert.AreEqual (1001, keys4 [0].Value, "DataKey.Value from ControlState");
Assert.AreEqual (2, keys4 [0].Values.Count, "DataKey.Values count from ControlState");
Assert.AreEqual (1001, keys4 [0].Values [0], "DataKey.Values[0] from ControlState");
Assert.AreEqual ("Mahesh", keys4 [0].Values [1], "DataKey.Values[1] from ControlState");
}
示例4: GridView_Pager_Load
public static void GridView_Pager_Load (Page p)
{
// TopAndBottom, PageCount = 1
PokerGridView grid = new PokerGridView ();
grid.PagerSettings.Position = PagerPosition.TopAndBottom;
grid.AllowPaging = true;
p.Form.Controls.Add (grid);
grid.DataSource = new string [] { "A", "B", "C" };
grid.DataBind ();
Assert.AreEqual (1, grid.PageCount, "#1#PageCount");
Assert.IsNotNull (grid.TopPagerRow, "#1#TopPagerRow");
Assert.AreEqual (false, grid.TopPagerRow.Visible, "#1#TopPagerRow.Visible");
Assert.IsNotNull (grid.BottomPagerRow, "#1#BottomPagerRow");
Assert.AreEqual (false, grid.BottomPagerRow.Visible, "#1#BottomPagerRow.Visible");
// Top, PageCount = 1
grid = new PokerGridView ();
grid.PagerSettings.Position = PagerPosition.Top;
grid.AllowPaging = true;
p.Form.Controls.Add (grid);
grid.DataSource = new string [] { "A", "B", "C" };
grid.DataBind ();
Assert.AreEqual (1, grid.PageCount, "#2#PageCount");
Assert.IsNotNull (grid.TopPagerRow, "#2#TopPagerRow");
Assert.AreEqual (false, grid.TopPagerRow.Visible, "#2#TopPagerRow.Visible");
Assert.IsNull (grid.BottomPagerRow, "#2#BottomPagerRow");
// Bottom, PageCount = 1
grid = new PokerGridView ();
grid.PagerSettings.Position = PagerPosition.Bottom;
grid.AllowPaging = true;
p.Form.Controls.Add (grid);
grid.DataSource = new string [] { "A", "B", "C" };
grid.DataBind ();
Assert.AreEqual (1, grid.PageCount, "#3#PageCount");
Assert.IsNull (grid.TopPagerRow, "#3#TopPagerRow");
Assert.IsNotNull (grid.BottomPagerRow, "#3#BottomPagerRow");
Assert.AreEqual (false, grid.BottomPagerRow.Visible, "#3#BottomPagerRow.Visible");
// PagerSettings.Visible = false, PageCount = 2
grid = new PokerGridView ();
grid.PagerSettings.Position = PagerPosition.TopAndBottom;
grid.PagerSettings.Visible = false;
grid.AllowPaging = true;
grid.PageSize = 2;
p.Form.Controls.Add (grid);
grid.DataSource = new string [] { "A", "B", "C" };
grid.DataBind ();
Assert.AreEqual (2, grid.PageCount, "#3#PageCount");
Assert.IsNull (grid.TopPagerRow, "#3#TopPagerRow");
Assert.IsNull (grid.BottomPagerRow, "#3#BottomPagerRow");
}
示例5: GridView_Sort_and_DataSourceSelectArguments
public void GridView_Sort_and_DataSourceSelectArguments ()
{
DataSourceView view;
DataSourceSelectArguments arg;
Page p = new Page ();
PokerGridView g = new PokerGridView ();
g.Columns.Add (new BoundField ());
g.AllowSorting = true;
p.Controls.Add (g);
ObjectDataSource data = new ObjectDataSource ();
data.TypeName = typeof (DataSourceObject).AssemblyQualifiedName;
data.SelectMethod = "GetList";
data.SortParameterName = "sortExpression";
data.ID = "Data";
p.Controls.Add (data);
g.DataSourceID = "Data";
g.EditIndex = 2;
g.PageIndex = 1;
g.DataBind ();
g.Sort ("sort", SortDirection.Descending);
Assert.AreEqual (-1, g.EditIndex, "EditIndex after Sort, Bound by DataSourceID");
Assert.AreEqual (0, g.PageIndex, "PageIndex after Sort, Bound by DataSourceID");
arg = g.DoCreateDataSourceSelectArguments();
view = g.DoGetData ();
Assert.IsTrue (view.CanSort);
Assert.AreEqual ("sort", g.SortExpression, "SortExpression, Bound by DataSourceID");
Assert.AreEqual (SortDirection.Descending, g.SortDirection, "SortDirection, Bound by DataSourceID");
Assert.AreEqual ("sort DESC", arg.SortExpression, "AllowSorting = true, Bound by DataSourceID");
g.AllowSorting = false;
arg = g.DoCreateDataSourceSelectArguments ();
Assert.AreEqual ("sort DESC", arg.SortExpression, "AllowSorting = false, Bound by DataSourceID");
}
示例6: GridView_DeleteItem
public void GridView_DeleteItem ()
{
PokerGridView g = new PokerGridView ();
ArrayList myds = new ArrayList ();
myds.Add ("Norway");
myds.Add ("Sweden");
myds.Add ("France");
myds.Add ("Italy");
g.DataSource = myds;
g.DataBind ();
Assert.AreEqual (false, deleteitemchecker, "DeleteItem#1");
g.RowDeleting += new GridViewDeleteEventHandler (RowDeletingHandler);
g.DeleteRow (0);
Assert.AreEqual (true, deleteitemchecker, "DeleteItem#2");
}
示例7: GridView_NullDS
public void GridView_NullDS ()
{
PokerGridView g = new PokerGridView ();
g.DataSource = null;
g.DataBind ();
Assert.AreEqual (0, g.Rows.Count, "NullDS");
}
示例8: RenderAllowPaging2
public static void RenderAllowPaging2 (Page p)
{
ArrayList myds = new ArrayList ();
myds.Add ("Norway");
myds.Add ("Sweden");
myds.Add ("France");
myds.Add ("Italy");
myds.Add ("Norway");
myds.Add ("Sweden");
myds.Add ("France");
myds.Add ("Italy");
myds.Add ("Norway");
myds.Add ("Sweden");
myds.Add ("France");
myds.Add ("Italy");
LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG);
LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG);
PokerGridView b = new PokerGridView ();
p.Form.Controls.Add (lcb);
p.Form.Controls.Add (b);
b.AllowPaging = true;
b.PageSize = 2;
b.PageIndex = 1;
b.PagerSettings.PageButtonCount = 4;
b.PagerSettings.Mode= PagerButtons.NumericFirstLast;
b.DataSource = myds;
b.DataBind ();
p.Form.Controls.Add (lce);
}
示例9: RenderProperty
public static void RenderProperty (Page p)
{
// Array list for simple datasource
ArrayList myds = new ArrayList ();
myds.Add ("Norway");
myds.Add ("Sweden");
myds.Add ("France");
myds.Add ("Italy");
// Helper controls for searching usefull data from page
LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG);
LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG);
PokerGridView g = new PokerGridView ();
// Changing some property for test
g.AutoGenerateDeleteButton = true;
g.AutoGenerateEditButton = true;
g.BackImageUrl = "http://test";
g.Caption = "test";
g.CaptionAlign = TableCaptionAlign.Left;
g.CellPadding = 0;
g.CellSpacing = 1;
g.EnableSortingAndPagingCallbacks = true;
g.GridLines = GridLines.Horizontal;
g.HorizontalAlign = HorizontalAlign.Justify;
g.ShowFooter = true;
g.ShowHeader = false;
g.UseAccessibleHeader = false;
// Add controls for page
p.Form.Controls.Add (lcb);
p.Form.Controls.Add (g);
// Data source and bind
g.DataSource = myds;
g.DataBind ();
p.Form.Controls.Add (lce);
}
示例10: GridView_Render
public void GridView_Render ()
{
PokerGridView b = new PokerGridView ();
b.DataSource = myds;
b.DataBind ();
string OriginControlHtml = "<div>\r\n\t<table cellspacing=\"0\" rules=\"all\" border=\"1\" style=\"border-collapse:collapse;\">\r\n\t\t<tr>\r\n\t\t\t<th scope=\"col\">Item</th>\r\n\t\t</tr><tr>\r\n\t\t\t<td>Norway</td>\r\n\t\t</tr><tr>\r\n\t\t\t<td>Sweden</td>\r\n\t\t</tr><tr>\r\n\t\t\t<td>France</td>\r\n\t\t</tr><tr>\r\n\t\t\t<td>Italy</td>\r\n\t\t</tr><tr>\r\n\t\t\t<td>Israel</td>\r\n\t\t</tr><tr>\r\n\t\t\t<td>Russia</td>\r\n\t\t</tr>\r\n\t</table>\r\n</div>";
string RenderedControlHtml = b.Render ();
HtmlDiff.AssertAreEqual (OriginControlHtml, RenderedControlHtml, "Rendering");
}
示例11: RenderAllowPaging
public static void RenderAllowPaging (Page p)
{
ArrayList myds = new ArrayList ();
myds.Add ("Norway");
myds.Add ("Sweden");
myds.Add ("France");
myds.Add ("Italy");
LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG);
LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG);
PokerGridView b = new PokerGridView ();
p.Form.Controls.Add (lcb);
p.Form.Controls.Add (b);
b.AllowPaging = true;
b.PageSize = 2;
b.DataSource = myds;
b.DataBind ();
p.Form.Controls.Add (lce);
}
示例12: GridView_PrepareControlHierarchy
public void GridView_PrepareControlHierarchy ()
{
PokerGridView gv = new PokerGridView ();
gv.controlHierarchy = false;
gv.Render ();
Assert.AreEqual (0, gv.Controls.Count, "ControlHierarchy_ControlsCount");
Assert.AreEqual (true, gv.controlHierarchy, "ControlHierarchy_FirstFlow");
gv.DataSource = myds;
gv.DataBind ();
gv.controlHierarchy = false;
gv.Render ();
Assert.AreEqual (1, gv.Controls.Count, "ControlHierarchy_ControlsCountSecondaryFlow");
Assert.AreEqual (true, gv.controlHierarchy, "ControlHierarchy_SecondaryFlow");
}
示例13: GridView_BubbleEvent
public void GridView_BubbleEvent ()
{
PokerGridView gv = new PokerGridView ();
Page page = new Page ();
LinkButton lb = new LinkButton ();
gv.AllowPaging = true;
page.Controls.Add (gv);
gv.DataSource = myds;
gv.DataBind ();
gv.EditIndex = 0;
//
gv.RowDeleting += new GridViewDeleteEventHandler (gv_RowDeleting);
gv.RowUpdating += new GridViewUpdateEventHandler (gv_RowUpdating);
gv.RowEditing += new GridViewEditEventHandler (gv_RowEditing);
gv.Sorting += new GridViewSortEventHandler (gv_Sorting);
gv.RowCancelingEdit += new GridViewCancelEditEventHandler (gv_RowCancelingEdit);
gv.SelectedIndexChanging+=new GridViewSelectEventHandler(gv_SelectedIndexChanging);
gv.PageIndexChanging+=new GridViewPageEventHandler(gv_PageIndexChanging);
// Delete
GridViewCommandEventArgs com1 = new GridViewCommandEventArgs (lb, new CommandEventArgs ("Delete", "0"));
Assert.AreEqual (false, bubbledeleterow, "BeforeBubbleEventDeleteRow");
gv.DoOnBubbleEvent (gv, com1);
Assert.AreEqual (true, bubbledeleterow, "AfterBubbleEventDeleteRow");
// Update
GridViewCommandEventArgs com2 = new GridViewCommandEventArgs (lb, new CommandEventArgs ("Update", "0"));
Assert.AreEqual (false, bubbleupdaterow, "BeforeBubbleEventUpdateRow");
gv.DoOnBubbleEvent (gv, com2);
Assert.AreEqual (true, bubbleupdaterow, "AfterBubbleEventUpdateRow");
// Edit
GridViewCommandEventArgs com3 = new GridViewCommandEventArgs (lb, new CommandEventArgs ("Edit", "0"));
Assert.AreEqual (false, bubbleeditingrow, "BeforeBubbleEventEditingRow");
gv.DoOnBubbleEvent (gv, com3);
Assert.AreEqual (true, bubbleeditingrow, "AfterBubbleEventEditingRow");
// Sort
gv.AllowSorting = true;
GridViewCommandEventArgs com4 = new GridViewCommandEventArgs (lb, new CommandEventArgs ("Sort", null));
Assert.AreEqual (false, bubblesortint, "BeforeBubbleEventSortingRow");
gv.DoOnBubbleEvent (gv, com4);
Assert.AreEqual (true, bubblesortint, "AfterBubbleEventSortingRow");
// Canceling Edit
GridViewCommandEventArgs com5 = new GridViewCommandEventArgs (lb, new CommandEventArgs ("Cancel", null));
Assert.AreEqual (false, bubblecanceling, "BeforeBubbleEventcancelingEdit");
gv.DoOnBubbleEvent (gv, com5);
Assert.AreEqual (true, bubblecanceling, "AfterBubbleEventcancelingEdit");
// Select
GridViewCommandEventArgs com6 = new GridViewCommandEventArgs (gv.SelectedRow, lb, new CommandEventArgs ("Select", "2"));
Assert.AreEqual (false, bubbleselect, "BeforeBubbleEventSelect");
gv.DoOnBubbleEvent (gv, com6);
Assert.AreEqual (true, bubbleselect, "AfterBubbleEventSelect");
//Next Page
GridViewCommandEventArgs com7 = new GridViewCommandEventArgs (lb, new CommandEventArgs ("Page", "Next"));
Assert.AreEqual (false, bubblepage, "BeforeBubbleEventNextPage");
gv.DoOnBubbleEvent (gv, com7);
Assert.AreEqual (true, bubblepage, "AfterBubbleEventNextPage");
Assert.AreEqual (1, newPageIndex, "NextPage");
// Prev Page
ResetEvents ();
GridViewCommandEventArgs com8 = new GridViewCommandEventArgs (lb, new CommandEventArgs ("Page", "Prev"));
Assert.AreEqual (false, bubblepage, "BeforeBubbleEventPrevPage");
gv.DoOnBubbleEvent (gv, com8);
Assert.AreEqual (true, bubblepage, "AfterBubbleEventPrevPage");
Assert.AreEqual (-1, newPageIndex, "PrevPage");
ResetEvents ();
GridViewCommandEventArgs com9 = new GridViewCommandEventArgs (lb, new CommandEventArgs ("Page", "Last"));
Assert.AreEqual (false, bubblepage, "BeforeBubbleEventLastPage");
gv.DoOnBubbleEvent (gv, com9);
Assert.AreEqual (true, bubblepage, "AfterBubbleEventLastPage");
ResetEvents ();
GridViewCommandEventArgs com10 = new GridViewCommandEventArgs (lb, new CommandEventArgs ("Page", "First"));
Assert.AreEqual (false, bubblepage, "BeforeBubbleEventFirstPage");
gv.DoOnBubbleEvent (gv, com10);
Assert.AreEqual (true, bubblepage, "AfterBubbleEventFirstPage");
Assert.AreEqual (0, newPageIndex, "FirstPage");
}
示例14: GridView_InitializePager
public void GridView_InitializePager ()
{
PokerGridView gv = new PokerGridView ();
Page page = new Page ();
page.Controls.Add (gv);
gv.AllowPaging = true;
gv.PageSize = 2;
gv.DataSource = myds;
Assert.AreEqual (false, gv.ifPagerInitilized, "BeforeInitializePagerRunned");
Assert.AreEqual (0, gv.PageCount, "BeforeInitializePagerPageCount");
gv.DataBind ();
Assert.AreEqual (true, gv.ifPagerInitilized, "AfterInitializePagerRunned");
Assert.AreEqual (3, gv.PageCount, "AfterInitializePagerPageCount");
}
示例15: GridView_DataBind
public void GridView_DataBind()
{
PokerGridView g = new PokerGridView ();
g.DataSource = myds;
g.DataBind ();
Assert.AreEqual (6, g.Rows.Count, "DataBind");
g.DataSource = null;
g.DataBind ();
Assert.AreEqual (0, g.Rows.Count, "DataBind");
}