* PagedDataSource.cs (PrivateICollectionEnumerator.MoveNext):
[mono.git] / mcs / class / System.Web / System.Web.UI.WebControls / PagedDataSource.cs
index 407d76a1a844b58dbeec0ab416fbc3c3ac258d8d..3d1ec87478f023654509edd7ca9e32287be942bd 100644 (file)
@@ -73,7 +73,7 @@ namespace System.Web.UI.WebControls
                        {
                                if(dataSource != null)
                                {
-                                       if(IsPagingEnabled)
+                                       if(!IsPagingEnabled)
                                        {
                                                return DataSourceCount;
                                        }
@@ -168,7 +168,7 @@ namespace System.Web.UI.WebControls
                {
                        get
                        {
-                               return (!IsPagingEnabled || (CurrentPageIndex == PageCount));
+                               return (!IsPagingEnabled || (CurrentPageIndex == (PageCount - 1)));
                        }
                }
 
@@ -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()
@@ -347,6 +346,7 @@ namespace System.Web.UI.WebControls
                                        while(cIndex < start)
                                        {
                                                collEnum.MoveNext();
+                                               cIndex++;
                                        }
                                }
                                collEnum.MoveNext();