[Mono-bugs] [Bug 73864][Nor] New - DataGrid.PageCount behaviour inconsistent with MS' .NET

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Fri, 18 Mar 2005 22:19:37 -0500 (EST)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by bugzilla@patearl.net.

http://bugzilla.ximian.com/show_bug.cgi?id=73864

--- shadow/73864	2005-03-18 22:19:37.000000000 -0500
+++ shadow/73864.tmp.30646	2005-03-18 22:19:37.000000000 -0500
@@ -0,0 +1,89 @@
+Bug#: 73864
+Product: Mono: Class Libraries
+Version: unspecified
+OS: All
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: Sys.Data
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: bugzilla@patearl.net               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: DataGrid.PageCount behaviour inconsistent with MS' .NET
+
+Description of Problem:
+
+Under Microsoft's .NET, asking a datagrid for its PageCount returns 1 when
+there are 0 items in the datasource.  Mono returns 0 for the PageCount when
+there are 0 items.  This creates a problem when using the MxDataGrid
+provided with Microsoft's Web Matrix IDE.  Though I can't see the source
+code, the MxDataGrid seems to do something like this:
+
+  if(CurrentPageIndex < PageCount) {
+    throw new Exception('The current page index must be < PageCount');
+  }
+
+Steps to reproduce the problem:
+1.  Get the Microsoft.Matrix.Framework.dll file from Web Matrix.
+2.  Use the following page:
+
+<%@ Page Language="C#" %>
+<%@ Register TagPrefix="wmx" Namespace="Microsoft.Matrix.Framework.Web.UI"
+Assembly="Microsoft.Matrix.Framework, Version=0.6.0.0, Culture=neutral,
+PublicKeyToken=6f763c9966660626" %>
+<script runat="server">
+
+    void Page_Load(object sender, EventArgs e) {
+        MxDataGrid1.DataSource = new ArrayList();
+        MxDataGrid1.DataBind();
+    }
+
+</script>
+<html>
+<head>
+</head>
+<body>
+    <form runat="server">
+        <wmx:MxDataGrid id="MxDataGrid1"
+                        runat="server"
+                        AllowPaging="True"></wmx:MxDataGrid>
+    </form>
+</body>
+</html>
+
+Actual Results:
+  An exception occurs, saying:
+    Invalid CurrentPageIndex value.  It must be >= 0 and < the PageCount.
+
+Expected Results:
+  No exception should occur, the page should be empty.
+
+How often does this happen? 
+  All the time.
+
+Additional Information:
+
+To "fix" this, I edited the PageCount property in PagedDataSource.  I
+simply added the following line after it gets its total:
+
+    if (total == 0) return 1;
+
+Note that this is not a complete fix.  There was another patch submitted a
+while ago that changed the out of range comparison to CurrentPageIndex >
+PageCount.  Comparisons such as that should go back to being
+CurrentPageIndex >= PageCount.
+
+Replacing the above PageLoad code with the following code produces a
+CurrentPageIndex out of range exception on Microsoft's .NET:
+
+        ArrayList list = new ArrayList();
+        list.Add("One");
+        MxDataGrid1.PageSize = 1;
+        MxDataGrid1.DataSource = list;
+        MxDataGrid1.CurrentPageIndex = 1;
+        MxDataGrid1.DataBind();