Kaynağa Gözat

2006-11-14 Igor Zelmanovich <[email protected]>

	* CompositeDataBoundControl.cs: fixed: 
	DataBind call Controls.Clear().


svn path=/trunk/mcs/; revision=67843
Igor Zelmanovich 19 yıl önce
ebeveyn
işleme
3b57aec6ef

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

@@ -1,3 +1,8 @@
+2006-11-14 Igor Zelmanovich <[email protected]>
+
+	* CompositeDataBoundControl.cs: fixed: 
+	DataBind call Controls.Clear().
+
 2006-11-13 Igor Zelmanovich <[email protected]>
 
 	* CompositeDataBoundControl.cs: fixed: 

+ 1 - 1
mcs/class/System.Web/System.Web.UI.WebControls/CompositeDataBoundControl.cs

@@ -64,7 +64,7 @@ namespace System.Web.UI.WebControls
 		
 		protected internal override void PerformDataBinding (IEnumerable data)
 		{
-			ChildControlsCreated = true;
+			Controls.Clear ();
 			ViewState ["_ItemCount"] = CreateChildControls (data, true);
 		}
 		

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

@@ -1,3 +1,7 @@
+2006-11-14  Igor Zelmanovich   <[email protected]>
+
+	* CompositeDataBoundControlTest.cs: added tests.
+
 2006-11-13  Vladimir Krasnov  <[email protected]>
 
 	* LoginTest.cs: login tests converted to webtest

+ 16 - 0
mcs/class/System.Web/Test/System.Web.UI.WebControls/CompositeDataBoundControlTest.cs

@@ -51,10 +51,12 @@ namespace MonoTests.System.Web.UI.WebControls
 			public bool createChildControls2 = false;
 			public bool dataBind = false;
 			public bool CreateChildControls_ChildControlsCreated;
+			public int CreateChildControls_Controls_Count;
 
 			protected override int CreateChildControls (IEnumerable dataSource, bool dataBinding) {
 				createChildControls2 = true;
 				CreateChildControls_ChildControlsCreated = ChildControlsCreated;
+				CreateChildControls_Controls_Count = Controls.Count;
 				return 10;
 			}
 
@@ -133,6 +135,17 @@ namespace MonoTests.System.Web.UI.WebControls
 			c.DoCreateChildControls ();
 			Assert.AreEqual (0, c.Controls.Count);
 		}
+
+		[Test]
+		public void DetailsView_CreateChildControls_Clear2 () {
+			MyCompositeDataBoundControl c = new MyCompositeDataBoundControl ();
+			c.Controls.Add (new WebControl (HtmlTextWriterTag.A));
+			Assert.AreEqual (1, c.Controls.Count, "Controls.Count before DataBind");
+			c.DataBind ();
+			Assert.AreEqual (0, c.CreateChildControls_Controls_Count, "Controls.Count in CreateChildControls");
+			Assert.AreEqual (0, c.Controls.Count, "Controls.Count after DataBind");
+
+		}
 		
 		[Test]
 		public void DataBind_ChildControlsCreated () {
@@ -141,6 +154,9 @@ namespace MonoTests.System.Web.UI.WebControls
 			p.Controls.Add (c);
 			Assert.IsFalse (c.GetChildControlsCreated (), "ChildControlsCreated before DataBind");
 			c.DataBind ();
+			Assert.IsTrue (c.ensureCreateChildControls);
+			Assert.IsTrue (c.createChildControls1);
+			Assert.IsTrue (c.createChildControls2);
 			Assert.IsTrue (c.CreateChildControls_ChildControlsCreated, "ChildControlsCreated in CreateChildControls");
 			Assert.IsTrue (c.GetChildControlsCreated (), "ChildControlsCreated after DataBind");
 		}