浏览代码

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

	* ListControl.cs: fixed: DataBinding for 2.0, for 1.x - refactoring only.


svn path=/trunk/mcs/; revision=67903
Igor Zelmanovich 19 年之前
父节点
当前提交
1788a41ecf

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

@@ -1,3 +1,7 @@
+2006-11-15 Igor Zelmanovich <[email protected]>
+
+	* ListControl.cs: fixed: DataBinding for 2.0, for 1.x - refactoring only.
+
 2006-11-14 Igor Zelmanovich <[email protected]>
 
 	* GridView.cs: fixed: Rows property, DataBinding flow.

+ 7 - 7
mcs/class/System.Web/System.Web.UI.WebControls/ListControl.cs

@@ -338,14 +338,7 @@ namespace System.Web.UI.WebControls {
 			IEnumerable list = DataSourceResolver.ResolveDataSource (DataSource, DataMember);
 			if (list == null)
 				return;
-#endif
 
-#if NET_2_0
-			if (!AppendDataBoundItems)
-#endif
-				Items.Clear();
-
-#if !NET_2_0
 			DoDataBinding (list);
 #endif
 		}
@@ -363,6 +356,11 @@ namespace System.Web.UI.WebControls {
 		void DoDataBinding (IEnumerable dataSource)
 		{
 			if (dataSource != null) {
+#if NET_2_0
+				if (!AppendDataBoundItems)
+#endif
+					Items.Clear ();
+
 				string format = DataTextFormatString;
 				if (format == "")
 					format = null;
@@ -419,6 +417,8 @@ namespace System.Web.UI.WebControls {
 		{
 			base.PerformDataBinding (dataSource);
 
+			if (dataSource == null)
+				return;
 			DoDataBinding (dataSource);
 		}
 

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

@@ -1,3 +1,7 @@
+2006-11-15  Igor Zelmanovich   <[email protected]>
+
+	* ListControlTest.cs: added test.
+
 2006-11-14  Igor Zelmanovich   <[email protected]>
 
 	* BaseDataBoundControlTest.cs: added tests.

+ 15 - 0
mcs/class/System.Web/Test/System.Web.UI.WebControls/ListControlTest.cs

@@ -423,6 +423,21 @@ namespace MonoTests.System.Web.UI.WebControls {
 			p.DataBind ();
 		}
 
+		[Test]
+		public void DataBinding6 () {
+			ListControlPoker p = new ListControlPoker ();
+			ArrayList list = new ArrayList ();
+			list.Add (1);
+			list.Add (2);
+			list.Add (3);
+			p.DataSource = list;
+			p.DataBind ();
+			Assert.AreEqual (3, p.Items.Count, "#01");
+			p.DataSource = null;
+			p.DataBind ();
+			Assert.AreEqual (3, p.Items.Count, "#01");
+		}
+
 		class Data {
 			string name;
 			object val;