mail-archives/mono-bugs/2006-February/039314.html

210 строки
8.3 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE> [Mono-bugs] [Bug 77573][Wis] New - DataGrid / PagedDatasource Error
when using DataTable as DataSource
</TITLE>
<LINK REL="Index" HREF="index.html" >
<LINK REL="made" HREF="mailto:mono-bugs%40lists.ximian.com?Subject=%5BMono-bugs%5D%20%5BBug%2077573%5D%5BWis%5D%20New%20-%20DataGrid%20/%20PagedDatasource%20Error%0A%09when%20using%20DataTable%20as%20DataSource&In-Reply-To=bug-77573%40chernobyl.ximian.com">
<META NAME="robots" CONTENT="index,nofollow">
<META http-equiv="Content-Type" content="text/html; charset=us-ascii">
<LINK REL="Previous" HREF="039313.html">
<LINK REL="Next" HREF="039315.html">
</HEAD>
<BODY BGCOLOR="#ffffff">
<H1>[Mono-bugs] [Bug 77573][Wis] New - DataGrid / PagedDatasource Error
when using DataTable as DataSource</H1>
<B>bugzilla-daemon at bugzilla.ximian.com</B>
<A HREF="mailto:mono-bugs%40lists.ximian.com?Subject=%5BMono-bugs%5D%20%5BBug%2077573%5D%5BWis%5D%20New%20-%20DataGrid%20/%20PagedDatasource%20Error%0A%09when%20using%20DataTable%20as%20DataSource&In-Reply-To=bug-77573%40chernobyl.ximian.com"
TITLE="[Mono-bugs] [Bug 77573][Wis] New - DataGrid / PagedDatasource Error
when using DataTable as DataSource">bugzilla-daemon at bugzilla.ximian.com
</A><BR>
<I>Wed Feb 15 21:48:49 EST 2006</I>
<P><UL>
<LI>Previous message: <A HREF="039313.html">[Mono-bugs] [Bug 77572][Nor] New - Segmentation fault in
asynchronous I/O
</A></li>
<LI>Next message: <A HREF="039315.html">[Mono-bugs] [Bug 77562][Maj] Changed - Missing interface
implementation
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#39314">[ date ]</a>
<a href="thread.html#39314">[ thread ]</a>
<a href="subject.html#39314">[ subject ]</a>
<a href="author.html#39314">[ author ]</a>
</LI>
</UL>
<HR>
<!--beginarticle-->
<PRE>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 <A HREF="http://lists.ximian.com/mailman/listinfo/mono-bugs">monobugzilla at yellowguppy.com.</A>
<A HREF="http://bugzilla.ximian.com/show_bug.cgi?id=77573">http://bugzilla.ximian.com/show_bug.cgi?id=77573</A>
--- 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
+Resolution:
+Severity:
+Priority: Wishlist
+Component: Sys.Web
+AssignedTo: <A HREF="http://lists.ximian.com/mailman/listinfo/mono-bugs">gonzalo at ximian.com</A>
+ReportedBy: <A HREF="http://lists.ximian.com/mailman/listinfo/mono-bugs">monobugzilla at yellowguppy.com</A>
+QAContact: <A HREF="http://lists.ximian.com/mailman/listinfo/mono-bugs">mono-bugs at ximian.com</A>
+TargetMilestone: ---
+URL:
+Cc:
+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..
+
+&lt;0x00175&gt; System.Web.UI.WebControls.PagedDataSource:get_DataSourceCount ()
+in &lt;0x00034&gt; System.Web.UI.WebControls.PagedDataSource:get_PageCount () in
+&lt;0x000ce&gt; System.Web.UI.WebControls.DataGrid:InitializeNumericPager
+(System.Web.UI.WebControls.DataGridItem item, Int32 columnSpan,
+System.Web.UI.WebControls.PagedDataSource paged) in &lt;0x00051&gt;
+System.Web.UI.WebControls.DataGrid:InitializePager
+(System.Web.UI.WebControls.DataGridItem item, Int32 columnSpan,
+System.Web.UI.WebControls.PagedDataSource pagedDataSource) in &lt;0x000a7&gt;
+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 &lt;0x00273&gt;
+System.Web.UI.WebControls.DataGrid:CreateControlHierarchy (Boolean
+useDataSource) in &lt;0x00095&gt; System.Web.UI.WebControls.BaseDataList:DataBind ()
+
+The datagrid definition is..
+
+&lt;asp:DataGrid id=&quot;DataGrid1&quot; runat=&quot;server&quot; AutoGenerateColumns=&quot;False&quot;
+PageSize=&quot;20&quot; AllowPaging=&quot;True&quot; CssClass=&quot;datatable&quot;&gt;
+...
+&lt;PagerStyle Mode=&quot;NumericPages&quot;&gt;
+&lt;/PagerStyle&gt;
+&lt;/asp:DataGrid&gt;
+
+The error generated on the webform is..
+
+*Error Message: *HTTP 500. The data source must implement ICollection
+
+This error appears to maps back to
+<A HREF="http://svn.myrealbox.com/source/trunk/mcs/class/System.Web/System.Web.UI.WebControls/PagedDataSource.cs">http://svn.myrealbox.com/source/trunk/mcs/class/System.Web/System.Web.UI.WebControls/PagedDataSource.cs</A>
+
+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 (&quot;The data source must implement ICollection&quot;);
+}
+}
+
+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
+appropriate.
+
+public IEnumerator GetEnumerator ()
+{
+
+// IList goes first, as it implements ICollection
+
+&gt; IList list
+&gt; if (source is IListSource) {
+&gt; list = ((IListSource) source).GetList();
+&gt; else {
+&gt; list = source as IList;
+&gt; }
+
+
+int first = 0;
+int count;
+int limit;
+if (list != null) {
+first = FirstIndexInPage;
+count = ((ICollection) source).Count;
+limit = ((first + page_size) &gt; 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) &gt; 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 1.1.13.1-1 libraries for the Mono JIT
+ii mono 1.1.13.1-1 Mono CLI (.NET) runtime
+ii mono-apache-server 1.1.13-0pre1 backend for mod_mono Apache
+module
+ii mono-assemblies-base 1.1.13.1-1 Mono class library -
+transistion package
+ii mono-classlib-1.0 1.1.13.1-1 Mono class library (1.0)
+ii mono-classlib-2.0 1.1.13.1-1 Mono class library (2.0)
+ii mono-common 1.1.13.1-1 common files for Mono
+ii mono-gmcs 1.1.13.1-1 Mono C# 2.0 compiler
+ii mono-jit 1.1.13.1-1 fast CLI JIT/AOT compiler for
+Mono
+ii mono-mcs 1.1.13.1-1 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
</PRE>
<!--endarticle-->
<HR>
<P><UL>
<!--threads-->
<LI>Previous message: <A HREF="039313.html">[Mono-bugs] [Bug 77572][Nor] New - Segmentation fault in
asynchronous I/O
</A></li>
<LI>Next message: <A HREF="039315.html">[Mono-bugs] [Bug 77562][Maj] Changed - Missing interface
implementation
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#39314">[ date ]</a>
<a href="thread.html#39314">[ thread ]</a>
<a href="subject.html#39314">[ subject ]</a>
<a href="author.html#39314">[ author ]</a>
</LI>
</UL>
<hr>
<a href="http://lists.ximian.com/mailman/listinfo/mono-bugs">More information about the mono-bugs
mailing list</a><br>
</body></html>