[Mono-bugs] [Bug 77573][Wis] New - DataGrid / PagedDatasource Error when using DataTable as DataSource

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Wed Feb 15 21:48:49 EST 2006

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 monobugzilla at yellowguppy.com.


--- shadow/77573	2006-02-15 21:48:49.000000000 -0500
+++ shadow/77573.tmp.30951	2006-02-15 21:48:49.000000000 -0500
@@ -0,0 +1,136 @@
+Bug#: 77573
+Product: Mono: Class Libraries
+Version: 1.1
+OS: GNU/Linux [Other]
+OS Details: Linux gordon 2.4.27-2-386 Debian testing
+Status: NEW   
+Priority: Wishlist
+Component: Sys.Web
+AssignedTo: gonzalo at ximian.com                            
+ReportedBy: monobugzilla at yellowguppy.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+Summary: DataGrid / PagedDatasource Error when using DataTable as DataSource
+I have a datagrid in an form which has the DataSource set with a
+System.Data.DataTable.  On the MS runtime the datagrid, successfully
+databinds and displays the data.
+On Mono, it fails with the error..
+<0x00175> System.Web.UI.WebControls.PagedDataSource:get_DataSourceCount ()
+in <0x00034> System.Web.UI.WebControls.PagedDataSource:get_PageCount () in
+<0x000ce> System.Web.UI.WebControls.DataGrid:InitializeNumericPager
+(System.Web.UI.WebControls.DataGridItem item, Int32 columnSpan,
+System.Web.UI.WebControls.PagedDataSource paged) in <0x00051>
+(System.Web.UI.WebControls.DataGridItem item, Int32 columnSpan,
+System.Web.UI.WebControls.PagedDataSource pagedDataSource) in <0x000a7>
+System.Web.UI.WebControls.DataGrid:CreateItem (Int32 item_index, Int32
+data_source_index, ListItemType type, Boolean data_bind, System.Object
+data_item, System.Web.UI.WebControls.PagedDataSource paged) in <0x00273>
+System.Web.UI.WebControls.DataGrid:CreateControlHierarchy (Boolean
+useDataSource) in <0x00095> System.Web.UI.WebControls.BaseDataList:DataBind ()
+The datagrid definition is..
+<asp:DataGrid id="DataGrid1" runat="server" AutoGenerateColumns="False"
+PageSize="20" AllowPaging="True" CssClass="datatable">
+<PagerStyle Mode="NumericPages">
+The error generated on the webform is..
+*Error Message: *HTTP 500. The data source must implement ICollection
+This error appears to maps back to
+public int DataSourceCount {
+get {
+if (source == null)
+return 0;
+if (IsCustomPagingEnabled)
+return virtual_count;
+if (source is ICollection)
+return ((ICollection) source).Count;
+throw new HttpException ("The data source must implement ICollection");
+Since a DataTable doesn't implement ICollection directely it appears to be
+causing the problem?  Should something like the following be added to the
+DataSourceCount method before the error is thrown?
+if (source is IListSource) {
+return ((ICollection) ((IListSource)source).GetList() ).Count;
+Additionally, the GetEnumerator method doesn't appear to anticipate a
+DataTable or IListSource object.  Something like the following might be
+public IEnumerator GetEnumerator ()
+// IList goes first, as it implements ICollection
+> IList list
+> if (source is IListSource) {
+>  list = ((IListSource) source).GetList();
+> else {
+>   list = source as IList;
+> }
+int first = 0;
+int count;
+int limit;
+if (list != null) {
+first = FirstIndexInPage;
+count = ((ICollection) source).Count;
+limit = ((first + page_size) > count) ? (count - first) : page_size;
+return GetListEnum (list, first, first + limit);
+ICollection col = source as ICollection;
+if (col != null) {
+first = FirstIndexInPage;
+count = col.Count;
+limit = ((first + page_size) > count) ? (count - first) : page_size;
+return GetEnumeratorEnum (col.GetEnumerator (), first, first + page_size);
+return source.GetEnumerator ();
+The software that I have installed is..
+ii  libapache2-mod-mono        1.1.13-0pre3   Run ASP.NET Pages on UNIX
+with Apache 2 and Mo
+ii  libmono0              libraries for the Mono JIT
+ii  mono                  Mono CLI (.NET) runtime
+ii  mono-apache-server         1.1.13-0pre1   backend for mod_mono Apache
+ii  mono-assemblies-base     Mono class library -
+transistion package
+ii  mono-classlib-1.0     Mono class library (1.0)
+ii  mono-classlib-2.0     Mono class library (2.0)
+ii  mono-common           common files for Mono
+ii  mono-gmcs             Mono C# 2.0 compiler
+ii  mono-jit              fast CLI JIT/AOT compiler for
+ii  mono-mcs              Mono C# compiler
+ii  mono-xsp                   1.0.5-2        simple web server to run
+ASP.NET applications
+ii  mono-xsp-base              1.1.13-0pre1   base libraries for XSP 1.1
+ii  mono-xsp2-base             1.1.13-0pre1   base libraries for XSP 2.0

More information about the mono-bugs mailing list