[Mono-bugs] [Bug 51759][Maj] New - DataBinder.cs bug in MONO 0.29 when Container.DataItem is a CLR array

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Thu, 4 Dec 2003 22:51:51 -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 davidandrewtaylor@hotmail.com.


--- shadow/51759	2003-12-04 22:51:51.000000000 -0500
+++ shadow/51759.tmp.17932	2003-12-04 22:51:51.000000000 -0500
@@ -0,0 +1,56 @@
+Bug#: 51759
+Product: Mono/Class Libraries
+Version: unspecified
+OS Details: 
+Status: NEW   
+Severity: 004 Four hours
+Priority: Major
+Component: System.Web
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: davidandrewtaylor@hotmail.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+Summary: DataBinder.cs bug in MONO 0.29 when Container.DataItem is a CLR array
+MONO VERSION 0.29 Friday 5th December
+BUG IN FILE: System.Web.UI.DataBinder.cs.
+METHOD: (Line 65) public static object GetIndexedPropetyValue (object 
+container, string expr) 
+REPORTED BY: David Taylor (david.taylor@melbourneit.com.au)
+Summary of bug fix required:
+** Need to handle CLR arrays (which are different to Indexers which are 
+supported currently).
+If you databind against a collection and the expression evaluated 
+contains an indexed value, the current version of MONO works fine if an 
+Indexer has been implemented (as in the System.Collection classes).  
+However it will *not* work if Container.DataItem is a CLR array.
+Line 111 gets the custom attribute "DefaultMemberAttribute" to find the 
+indexer of the type.  However CLR arrays do not have this attribute so an 
+exception is thrown.
+This method needs to be updated to detect if Container.DataItem is 
+actually an array (do this via reflection), and then use the correct 
+methods to read the indexes value.
+Code Example:
+//Code in Page_Load
+ArrayList list = new ArrayList();
+menuText.Add(new string[] {"Page 1", "http://blahblah"});
+menuText.Add(new string[] {"Page 2", "http://blahblah"});
+MenuItems.DataSource = list;
+*** Code on ASPX Page in say a DataList template.
+<%# DataBinder.Eval(Container, "DataItem[0]") %>
+This will fail because MONO looks for the "DefaultMemberAttribute" which 
+does not make sence for a CLR array!  It needs to be updated to also 
+support CLR Arrays.