فهرست منبع

BaseDataList.cs: added ConnectToDataSource method that called from OnLoad, fixed GetData method
Wizard.cs: fixed bug when called MoveTo after that control hierarchy has been created


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

Vladimir Krasnov 19 سال پیش
والد
کامیت
ff18cef286

+ 25 - 13
mcs/class/System.Web/System.Web.UI.WebControls/BaseDataList.cs

@@ -47,6 +47,7 @@ namespace System.Web.UI.WebControls {
 		private object source;
 #if NET_2_0
 		//private string dataSourceId;
+		IDataSource boundDataSource = null;
 		private bool initialized;
 		private bool requiresDataBinding;
 		private DataSourceSelectArguments selectArguments;
@@ -365,20 +366,10 @@ namespace System.Web.UI.WebControls {
 			if (DataSourceID.Length == 0)
 				return null;
 
-			IDataSource ds = null;
+			if (boundDataSource == null)
+				ConnectToDataSource ();
 
-			if (NamingContainer != null)
-				ds = (NamingContainer.FindControl (DataSourceID) as IDataSource);
-
-			if (ds == null) {
-				if (Parent != null)
-					ds = (Parent.FindControl (DataSourceID) as IDataSource);
-
-				if (ds == null)
-					throw new HttpException (Locale.GetText ("Coulnd't find a DataSource named '{0}'.", DataSourceID));
-			}
-
-			DataSourceView dsv = ds.GetView (String.Empty);
+			DataSourceView dsv = boundDataSource.GetView (String.Empty);
 			dsv.Select (SelectArguments, new DataSourceViewSelectCallback (SelectCallback));
 			return data;
 		}
@@ -408,6 +399,9 @@ namespace System.Web.UI.WebControls {
 			if ((Page != null) && !Page.IsPostBack)
 				RequiresDataBinding = true;
 
+			if (IsBoundUsingDataSourceID)
+				ConnectToDataSource ();
+
 			initialized = true;
 			base.OnLoad (e);
 		}
@@ -476,5 +470,23 @@ namespace System.Web.UI.WebControls {
 				return false;
 			}
 		}
+
+#if NET_2_0
+		void ConnectToDataSource ()
+		{
+			if (NamingContainer != null)
+				boundDataSource = (NamingContainer.FindControl (DataSourceID) as IDataSource);
+
+			if (boundDataSource == null) {
+				if (Parent != null)
+					boundDataSource = (Parent.FindControl (DataSourceID) as IDataSource);
+
+				if (boundDataSource == null)
+					throw new HttpException (Locale.GetText ("Coulnd't find a DataSource named '{0}'.", DataSourceID));
+			}
+			DataSourceView dsv = boundDataSource.GetView (String.Empty);
+			dsv.DataSourceViewChanged += new EventHandler (OnDataSourceViewChanged);
+		}
+#endif
 	}
 }

+ 7 - 0
mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog

@@ -1,3 +1,10 @@
+2006-06-14  Vladimir Krasnov  <[email protected]>
+
+	* BaseDataList.cs: added ConnectToDataSource method that called from 
+	OnLoad, fixed GetData method
+	* Wizard.cs: fixed bug when called MoveTo after that control hierarchy
+	has been created
+
 2006-06-14  Andrew Skiba <[email protected]>
 
 	* Menu.cs: add CssStyle value to the rendered class attribute

+ 3 - 0
mcs/class/System.Web/System.Web.UI.WebControls/Wizard.cs

@@ -1219,6 +1219,9 @@ namespace System.Web.UI.WebControls
 		
 		protected internal override void Render (HtmlTextWriter writer)
 		{
+			if (multiView.ActiveViewIndex != ActiveStepIndex)
+				CreateControlHierarchy ();
+
 			wizardTable.ApplyStyle (ControlStyle);
 
 			foreach (object[] styleDef in styles)