2008-02-25 Marek Habersack <mhabersack@novell.com>
authorMarek Habersack <grendel@twistedcode.net>
Mon, 25 Feb 2008 12:33:16 +0000 (12:33 -0000)
committerMarek Habersack <grendel@twistedcode.net>
Mon, 25 Feb 2008 12:33:16 +0000 (12:33 -0000)
* ControlBuilder.cs: correctly chain up to the parent builder when
looking for the naming container.
2008-02-25  Marek Habersack  <mhabersack@novell.com>

* TemplateControlCompiler.cs: GetContainerType now checks whether
the binding container returned from the builder implements
IDataItemContainer (for 2.0+ profiles) and looks for one more
property, Rows, if no Items property is found.

svn path=/trunk/mcs/; revision=96536

mcs/class/System.Web/System.Web.Compilation/ChangeLog
mcs/class/System.Web/System.Web.Compilation/TemplateControlCompiler.cs
mcs/class/System.Web/System.Web.UI/ChangeLog
mcs/class/System.Web/System.Web.UI/ControlBuilder.cs

index 960b0c20ec9ce42bd18e83e454fe6fbce1d96edd..cc2fecd57183a48f314c584166b064823e5aa455 100644 (file)
@@ -1,3 +1,10 @@
+2008-02-25  Marek Habersack  <mhabersack@novell.com>
+
+       * TemplateControlCompiler.cs: GetContainerType now checks whether
+       the binding container returned from the builder implements
+       IDataItemContainer (for 2.0+ profiles) and looks for one more
+       property, Rows, if no Items property is found.
+
 2008-02-08  Gert Driesen  <drieseng@users.sourceforge.net>
 
        * AppSettingsExpressionBuilder.cs: Improve exception messages. Return
index f86b1ee1c406ab4d59a17ac4f21841c97612b677..82da1cedb84dd6586ff4e8248bea120da05b25d9 100644 (file)
@@ -1153,17 +1153,35 @@ namespace System.Web.Compilation
                        parent.renderMethod.Statements.Add (AddLinePragma (expr, cr));
                }
 
+               static PropertyInfo GetContainerProperty (Type type, string[] propNames)
+               {
+                       PropertyInfo prop;
+                       
+                       foreach (string name in propNames) {
+                               prop = type.GetProperty (name, noCaseFlags & ~BindingFlags.NonPublic);
+                               if (prop != null)
+                                       return prop;
+                       }
+
+                       return null;
+               }
+
+               static string[] containerPropNames = {"Items", "Rows"};
+               
                static Type GetContainerType (ControlBuilder builder)
                {
                        TemplateBuilder tb = builder as TemplateBuilder;
                        if (tb != null && tb.ContainerType != null)
                                return tb.ContainerType;
-#if NET_2_0
-                       return builder.BindingContainerType;
-#else
+
                        Type type = builder.BindingContainerType;
 
-                       PropertyInfo prop = type.GetProperty ("Items", noCaseFlags & ~BindingFlags.NonPublic);
+#if NET_2_0
+                       if (typeof (IDataItemContainer).IsAssignableFrom (type))
+                               return type;
+#endif
+                       
+                       PropertyInfo prop = GetContainerProperty (type, containerPropNames);
                        if (prop == null)
                                return type;
 
@@ -1176,7 +1194,6 @@ namespace System.Web.Compilation
                                return type;
 
                        return prop.PropertyType;
-#endif
                }
                
                CodeMemberMethod CreateDBMethod (ControlBuilder builder, string name, Type container, Type target)
index 498c6743132266f1efde934082b4124c601d92d4..a92572f7970edf00239de76deaea308b1964baf5 100644 (file)
@@ -1,3 +1,8 @@
+2008-02-25  Marek Habersack  <mhabersack@novell.com>
+
+       * ControlBuilder.cs: correctly chain up to the parent builder when
+       looking for the naming container.
+
 2008-02-21  Marek Habersack  <mhabersack@novell.com>
 
        * ControlBuilder.cs: introduced a new internal property -
index 56e39df60ac20f2f823c98d6ab8677ebb0c61231..eff0abd90e91a3af87be1afb9a2eb3fb377ef6c7 100644 (file)
@@ -162,9 +162,9 @@ namespace System.Web.UI {
                                if (myNamingContainer == null) {
                                        Type controlType = parentBuilder != null ? parentBuilder.ControlType : null;
                                        
-                                       if (controlType == null)
+                                       if (parentBuilder == null && controlType == null)
                                                myNamingContainer = null;
-                                       else if (typeof (INamingContainer).IsAssignableFrom (controlType))
+                                       else if (controlType != null && typeof (INamingContainer).IsAssignableFrom (controlType))
                                                myNamingContainer = parentBuilder;
                                        else
                                                myNamingContainer = parentBuilder.MyNamingContainer;
@@ -189,7 +189,7 @@ namespace System.Web.UI {
                                if (cb is ContentBuilderInternal)
                                        return cb.BindingContainerType;
 #endif
-                               
+
                                return cb.ControlType;
                        }
                }