2007-07-01 Igor Zelmanovich <igorz@mainsoft.com>
authorIgor Zelmanovich <igorz@mono-cvs.ximian.com>
Sun, 1 Jul 2007 10:58:58 +0000 (10:58 -0000)
committerIgor Zelmanovich <igorz@mono-cvs.ximian.com>
Sun, 1 Jul 2007 10:58:58 +0000 (10:58 -0000)
* GridView.cs:
the Pager is created but unvisible for only one page.
the Patch submitted by Dumitru Ban [dban@dako.ro]

2007-07-01 Igor Zelmanovich <igorz@mainsoft.com>

* GridViewTest.cs:
Added new tests

svn path=/trunk/mcs/; revision=81139

mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
mcs/class/System.Web/System.Web.UI.WebControls/GridView.cs
mcs/class/System.Web/Test/System.Web.UI.WebControls/ChangeLog
mcs/class/System.Web/Test/System.Web.UI.WebControls/GridViewTest.cs

index a42cf20f650425668c0d0651b6cc88196e6ffbfa..960d051800a99c804fe68e4b69a63727814898e7 100644 (file)
@@ -1,3 +1,9 @@
+2007-07-01 Igor Zelmanovich <igorz@mainsoft.com>
+
+       * GridView.cs:
+       the Pager is created but unvisible for only one page. 
+       the Patch submitted by Dumitru Ban [dban@dako.ro]       
+
 2007-07-01 Igor Zelmanovich <igorz@mainsoft.com>
 
        * FormView.cs:
index b2c3f07b21c4c8b7ba401f7945ff169bc8f419e1..c6c00c4432029c06e640f7bc266838735cf9576a 100644 (file)
@@ -1263,8 +1263,8 @@ namespace System.Web.UI.WebControls
                                }
                        }
 
-                       bool showPager = AllowPaging && (PageCount > 1);
-                       
+                       bool createPager = AllowPaging && (PageCount >= 1) && PagerSettings.Visible;
+
                        ArrayList list = new ArrayList ();
                        
                        // Creates the set of fields to show
@@ -1297,7 +1297,7 @@ namespace System.Web.UI.WebControls
                                object obj = enumerator.Current;
                                
                                if (list.Count == 0) {
-                                       if (showPager && (PagerSettings.Position == PagerPosition.Top || PagerSettings.Position == PagerPosition.TopAndBottom)) {
+                                       if (createPager && (PagerSettings.Position == PagerPosition.Top || PagerSettings.Position == PagerPosition.TopAndBottom)) {
                                                topPagerRow = CreatePagerRow (fields.Length, dataSource);
                                                OnRowCreated (new GridViewRowEventArgs (topPagerRow));
                                                ContainedTable.Rows.Add (topPagerRow);
@@ -1305,6 +1305,8 @@ namespace System.Web.UI.WebControls
                                                        topPagerRow.DataBind ();
                                                        OnRowDataBound (new GridViewRowEventArgs (topPagerRow));
                                                }
+                                               if (PageCount == 1)
+                                                       topPagerRow.Visible = false;
                                        }
 
                                        GridViewRow headerRow = CreateRow (-1, -1, DataControlRowType.Header, DataControlRowState.Normal);
@@ -1355,7 +1357,7 @@ namespace System.Web.UI.WebControls
                                        OnRowDataBound (new GridViewRowEventArgs (footerRow));
                                }
 
-                               if (showPager && (PagerSettings.Position == PagerPosition.Bottom || PagerSettings.Position == PagerPosition.TopAndBottom)) {
+                               if (createPager && (PagerSettings.Position == PagerPosition.Bottom || PagerSettings.Position == PagerPosition.TopAndBottom)) {
                                        bottomPagerRow = CreatePagerRow (fields.Length, dataSource);
                                        OnRowCreated (new GridViewRowEventArgs (bottomPagerRow));
                                        ContainedTable.Rows.Add (bottomPagerRow);
@@ -1363,6 +1365,8 @@ namespace System.Web.UI.WebControls
                                                bottomPagerRow.DataBind ();
                                                OnRowDataBound (new GridViewRowEventArgs (bottomPagerRow));
                                        }
+                                       if (PageCount == 1)
+                                               bottomPagerRow.Visible = false;
                                }
                        }
 
index 3c4526671cd97d1337163d106bb1854133e75351..4ebf33e114a6b584c80d3e1abf4f776b13d4bf02 100644 (file)
@@ -1,3 +1,8 @@
+2007-07-01 Igor Zelmanovich <igorz@mainsoft.com>
+
+       * GridViewTest.cs:
+       Added new tests
+
 2007-07-01 Igor Zelmanovich <igorz@mainsoft.com>
 
        * FormViewTest.cs:
index 44bf9ba42bc4c405890f99030f5668aeeb1241f1..840eabac8b74ba082d632a1fcd661057560ed475 100644 (file)
@@ -3086,6 +3086,83 @@ namespace MonoTests.System.Web.UI.WebControls
 
                public static void BuildTemplateMethod (Control c) { }
 
+               [Test]
+               [Category ("NunitWeb")]
+               public void GridView_Pager () {
+                       PageDelegates delegates = new PageDelegates ();
+                       delegates.Load = GridView_Pager_Load;
+                       PageInvoker invoker = new PageInvoker (delegates);
+                       WebTest t = new WebTest (invoker);
+                       string html = t.Run ();
+               }
+
+               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");
+               }
+
         [TestFixtureTearDown]
         public void TearDown()
         {
@@ -3349,3 +3426,4 @@ namespace MonoTests.System.Web.UI.WebControls
 
 
 
+