* PagedDataSource.cs (PageCount): Return page count of 1 if there
authorJackson Harper <jackson@novell.com>
Mon, 3 Nov 2003 23:34:55 +0000 (23:34 -0000)
committerJackson Harper <jackson@novell.com>
Mon, 3 Nov 2003 23:34:55 +0000 (23:34 -0000)
paging is disabled. Patch by Yaron Shkop.
* PagedDataSource.cs (CopyTo): Improve. Patch by Yaron Shkop.
* TableStyle.cs (AddAttributesToRender): Render border style
collapse. Patch by Yaron Shkop.
* TableStyle.cs:
* TableItemStyle.cs:
* DataGridPagerStyle.cs: Call base copy and merge even if style is of
the wrong type. Patch by Yaron Shkop.

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

mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
mcs/class/System.Web/System.Web.UI.WebControls/DataGridPagerStyle.cs
mcs/class/System.Web/System.Web.UI.WebControls/PagedDataSource.cs
mcs/class/System.Web/System.Web.UI.WebControls/TableItemStyle.cs
mcs/class/System.Web/System.Web.UI.WebControls/TableStyle.cs

index ba0a206030a501a8b7ac2acb13e8f64b276adc87..02b65fe357ce96912d51aa0bee1db4741da1d73f 100644 (file)
@@ -1,3 +1,15 @@
+2003-11-03 Jackson Harper <jackson@ximian.com>
+
+       * PagedDataSource.cs (PageCount): Return page count of 1 if there
+       paging is disabled. Patch by Yaron Shkop.
+       * PagedDataSource.cs (CopyTo): Improve. Patch by Yaron Shkop.
+       * TableStyle.cs (AddAttributesToRender): Render border style
+       collapse. Patch by Yaron Shkop.
+       * TableStyle.cs:
+       * TableItemStyle.cs:
+       * DataGridPagerStyle.cs: Call base copy and merge even if style is of
+       the wrong type. Patch by Yaron Shkop.   
+       
 2003-11-03 Jackson Harper <jackson@ximian.com>
 
        * BoundColumn.cs: Render readonly columns. Patch by Mohammad DAMT.
index 08000143a660ce007f005730d8864390593dced8..761a6367346bbc738992716e56093a4f3af16748 100644 (file)
@@ -181,9 +181,11 @@ namespace System.Web.UI.WebControls
 
                public override void CopyFrom(Style s)
                {
-                       if(s != null && !s.IsEmpty && s is DataGridPagerStyle)
+                       if(s != null && !s.IsEmpty)
                        {
                                base.CopyFrom(s);
+                               if(!(s is DataGridPagerStyle)) return;
+
                                DataGridPagerStyle from = (DataGridPagerStyle)s;
                                if(from.IsSet(MODE))
                                {
@@ -214,9 +216,18 @@ namespace System.Web.UI.WebControls
 
                public override void MergeWith(Style s)
                {
-                       if(s != null && !s.IsEmpty && s is DataGridPagerStyle)
+                       if(s != null && !s.IsEmpty)
                        {
+                               if(base.IsEmpty)
+                               {
+                                       base.CopyFrom(s);
+                                       return;
+                               }
+
                                base.MergeWith(s);
+
+                               if(!(s is DataGridPagerStyle)) return;
+
                                DataGridPagerStyle with = (DataGridPagerStyle)s;
                                if(with.IsSet(MODE) && !IsSet(MODE))
                                {
index dc26a3bf5a997bc4f457f80e03585f5ec8085a3a..683700add5c1b4adef88f1acc3ed30323287c431 100644 (file)
@@ -200,13 +200,11 @@ namespace System.Web.UI.WebControls
                {
                        get
                        {
-                               if(dataSource != null)
-                               {
-                                       int total = DataSourceCount;
+                               if(dataSource != null) {
                                        if(!IsPagingEnabled)
-                                       {
-                                               return total;
-                                       }
+                                               return 1;
+                                        
+                                       int total = DataSourceCount;
                                        return (total + pageSize - 1)/pageSize;
                                }
                                return 0;
@@ -247,10 +245,11 @@ namespace System.Web.UI.WebControls
 
                public void CopyTo(Array array, int index)
                {
-                       foreach(object current in this)
-                       {
-                               array.SetValue(array, index++);
-                       }
+                       IEnumerator enumerator = this.GetEnumerator();
+                       if(enumerator == null) return;
+
+                       while(enumerator.MoveNext())
+                               array.SetValue(enumerator.Current, index++);
                }
 
                public IEnumerator GetEnumerator()
index cddc73434aae7c1c8bb433dc7cab49c940b24e5d..9e640279520017f254055e305ad0c089d1ef733c 100644 (file)
@@ -101,9 +101,13 @@ namespace System.Web.UI.WebControls
 \r
                public override void CopyFrom(Style s)\r
                {\r
-                       if(s!=null && s is TableItemStyle && !s.IsEmpty)\r
+                       if(s!=null && !s.IsEmpty)\r
                        {\r
                                base.CopyFrom(s);\r
+\r
+                               if (!(s is TableItemStyle))\r
+                                       return;\r
+                                \r
                                TableItemStyle from = (TableItemStyle)s;\r
                                if(from.IsSet(H_ALIGN))\r
                                {\r
@@ -122,9 +126,17 @@ namespace System.Web.UI.WebControls
 \r
                public override void MergeWith(Style s)\r
                {\r
-                       if(s!=null && s is TableItemStyle && !s.IsEmpty)\r
+                       if(s!=null && !s.IsEmpty)\r
                        {\r
+                               if (base.IsEmpty) {\r
+                                       base.CopyFrom (s);\r
+                                       return;\r
+                               }\r
                                base.MergeWith(s);\r
+\r
+                               if (!(s is TableItemStyle))\r
+                                       return;\r
+                               \r
                                TableItemStyle with = (TableItemStyle)s;\r
                                if(with.IsSet(H_ALIGN) && !IsSet(H_ALIGN))\r
                                {\r
index 75858441f72ade51a81ce0678741538c72a267f7..8733cdbb0cd59d183029d86e661498c3c7916337 100644 (file)
@@ -138,6 +138,9 @@ namespace System.Web.UI.WebControls
                        if(CellSpacing >= 0)\r
                        {\r
                                writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, CellSpacing.ToString(NumberFormatInfo.InvariantInfo));\r
+                               if(CellSpacing == 0)
+                                       writer.AddStyleAttribute(HtmlTextWriterStyle.BorderCollapse, "collapse");
+                               
                        }\r
                        if(CellPadding >= 0)\r
                        {\r
@@ -147,11 +150,10 @@ namespace System.Web.UI.WebControls
                        {\r
                                writer.AddAttribute(HtmlTextWriterAttribute.Align, Enum.Format(typeof(HorizontalAlign), HorizontalAlign, "G"));\r
                        }\r
-                       string gd = "";\r
+                       string gd = String.Empty;
                        switch(GridLines)\r
                        {\r
-                               case GridLines.None:       gd = "";\r
-                                                          break;\r
+                               case GridLines.None:       break;
                                case GridLines.Horizontal: gd = "rows";\r
                                                           break;\r
                                case GridLines.Vertical:   gd = "cols";\r
@@ -159,7 +161,6 @@ namespace System.Web.UI.WebControls
                                case GridLines.Both:       gd = "all";\r
                                                           break;\r
                        }
-                       if (gd != "")
                                writer.AddAttribute(HtmlTextWriterAttribute.Rules, gd);
                }
 
@@ -191,9 +192,17 @@ namespace System.Web.UI.WebControls
 
                public override void MergeWith(Style s)\r
                {\r
-                       if(s != null && s is TableStyle && !s.IsEmpty)\r
+                       if(s != null && !s.IsEmpty)\r
                        {\r
+                               if (base.IsEmpty) {
+                                       base.CopyFrom (s);
+                                       return;
+                               }
                                base.MergeWith(s);\r
+
+                               if (!(s is TableStyle))
+                                       return;
+                               
                                TableStyle with = (TableStyle)s;\r
                                if(with.IsSet(HOR_ALIGN) && IsSet(HOR_ALIGN))\r
                                {\r