refactoring
[mono.git] / mcs / class / System.Web / System.Web.UI.WebControls / HierarchicalDataBoundControl.cs
index b207af5e86f6d0b1008894be2f36aadebe75df4c..5cef14971ef66de2436f039197aed05d45e41b28 100644 (file)
 
 #if NET_2_0
 using System.Collections;
+using System.ComponentModel;
 
 namespace System.Web.UI.WebControls
 {
+       [DesignerAttribute ("System.Web.UI.Design.WebControls.HierarchicalDataBoundControlDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
        public abstract class HierarchicalDataBoundControl : BaseDataBoundControl
        {
+               [IDReferencePropertyAttribute (typeof(HierarchicalDataSourceControl))]
                public override string DataSourceID {
                        get {
                                object o = ViewState ["DataSourceID"];
@@ -51,7 +54,7 @@ namespace System.Web.UI.WebControls
                        }
                }
                
-               protected HierarchicalDataSourceView GetData (string viewPath)
+               protected virtual HierarchicalDataSourceView GetData (string viewPath)
                {
                        if (DataSource != null && DataSourceID != "")
                                throw new HttpException ();
@@ -63,13 +66,19 @@ namespace System.Web.UI.WebControls
                                return null; 
                }
                
-               protected IHierarchicalDataSource GetDataSource ()
+               protected virtual IHierarchicalDataSource GetDataSource ()
                {
                        if (DataSourceID != "")
                                return NamingContainer.FindControl (DataSourceID) as IHierarchicalDataSource;
                        
                        return DataSource as IHierarchicalDataSource;
                }
+
+               [MonoTODO]
+               protected void MarkAsDataBound ()
+               {
+                       throw new NotImplementedException ();
+               }
                
                protected override void OnDataPropertyChanged ()
                {
@@ -81,8 +90,11 @@ namespace System.Web.UI.WebControls
                        RequiresDataBinding = true;
                }
 
-               protected override void OnLoad (EventArgs e)
+               protected internal override void OnLoad (EventArgs e)
                {
+                       if (IsBoundUsingDataSourceID && (!Page.IsPostBack || !EnableViewState))
+                               RequiresDataBinding = true;
+               
                        IHierarchicalDataSource ds = GetDataSource ();
                        if (ds != null && DataSourceID != "")
                                ds.DataSourceChanged += new EventHandler (OnDataSourceChanged);
@@ -98,12 +110,13 @@ namespace System.Web.UI.WebControls
                
                protected internal virtual void PerformDataBinding ()
                {
-                       OnDataBinding (EventArgs.Empty);
                }
                
                protected override void PerformSelect ()
                {
+                       OnDataBinding (EventArgs.Empty);
                        PerformDataBinding ();
+                       OnDataBound (EventArgs.Empty);
                }
                
                protected override void ValidateDataSource (object dataSource)