Преглед на файлове

2008-04-03 Marek Habersack <[email protected]>

	* DataListTest.cs: added test for bug #376519
	(SelectedValue_SelectedIndex

2008-04-03  Marek Habersack  <[email protected]>

	* DataList.cs: use the value of SelectedIndex, not selectedIndex,
	to return the key value in the SelectedValue property. Fixes bug
	#376519. Patch from Sergey Kuleshov <[email protected]>, thanks

2008-04-03  Marek Habersack  <[email protected]>

	* HtmlFormTest.cs: indirect test for bug #376352 is 2.0+ only.

svn path=/trunk/mcs/; revision=99704
Marek Habersack преди 18 години
родител
ревизия
7876e9fdc1

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

@@ -1,3 +1,9 @@
+2008-04-03  Marek Habersack  <[email protected]>
+
+	* DataList.cs: use the value of SelectedIndex, not selectedIndex,
+	to return the key value in the SelectedValue property. Fixes bug
+	#376519. Patch from Sergey Kuleshov <[email protected]>, thanks!
+
 2008-03-12  Vladimir Krasnov  <[email protected]>
 
 	* AutoGeneratedField.cs, CheckBoxField.cs: fixed OnDataBindField,

+ 3 - 2
mcs/class/System.Web/System.Web.UI.WebControls/DataList.cs

@@ -470,8 +470,9 @@ namespace System.Web.UI.WebControls {
 				if (DataKeyField.Length == 0)
 					throw new InvalidOperationException (Locale.GetText ("No DataKeyField present."));
 
-				if ((SelectedIndex >= 0) && (selectedIndex < DataKeys.Count)) {
-					return DataKeys [selectedIndex];
+				int idx = SelectedIndex;
+				if ((idx >= 0) && (idx < DataKeys.Count)) {
+					return DataKeys [idx];
 				}
 
 				return null;

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

@@ -1,3 +1,7 @@
+2008-04-03  Marek Habersack  <[email protected]>
+
+	* HtmlFormTest.cs: indirect test for bug #376352 is 2.0+ only.
+
 2008-04-02  Marek Habersack  <[email protected]>
 
 	* HtmlFormTest.cs: added an indirect test for bug #376352

+ 4 - 0
mcs/class/System.Web/Test/System.Web.UI.HtmlControls/HtmlFormTest.cs

@@ -55,10 +55,12 @@ namespace MonoTests.System.Web.UI.HtmlControls {
 			}
 		}
 
+#if NET_2_0
 		public void SetContext ()
 		{
 			SetContext (Context);
 		}
+#endif
 	}
 	
 	public class FormPoker : HtmlForm {
@@ -198,6 +200,7 @@ namespace MonoTests.System.Web.UI.HtmlControls {
 			Assert.AreEqual ("target", a.GetAttribute ("target"), "A11");
 		}
 
+#if NET_2_0
 #if !TARGET_DOTNET
 		[Test]
 		public void ActionStringWithQuery ()
@@ -212,6 +215,7 @@ namespace MonoTests.System.Web.UI.HtmlControls {
 			// https://bugzilla.novell.com/show_bug.cgi?id=376352
 			Assert.AreEqual (" method=\"post\" action=\"?q=1\"", attrs, "A1");
 		}
+#endif
 #endif
 		
 		[Test]

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

@@ -1,3 +1,8 @@
+2008-04-03  Marek Habersack  <[email protected]>
+
+	* DataListTest.cs: added test for bug #376519
+	(SelectedValue_SelectedIndex)
+
 2008-03-09  Dean Brettle <[email protected]> 
 
 	* MenuTest.cs (Menu_RenderStaticItems): added tests to check that

+ 23 - 0
mcs/class/System.Web/Test/System.Web.UI.WebControls/DataListTest.cs

@@ -653,7 +653,30 @@ namespace MonoTests.System.Web.UI.WebControls {
 			Assert.IsNotNull (vs[i++], "GridLines");
 #endif
 		}
+
 #if NET_2_0
+		[Test]
+		public void SelectedValue_SelectedIndex ()
+		{
+			// Test for bug https://bugzilla.novell.com/show_bug.cgi?id=376519
+			DataTable table = new DataTable();
+			table.Columns.Add("id");
+			table.Columns.Add("text");
+
+			table.Rows.Add(new object[] {"id1", "Item N1"});
+			table.Rows.Add(new object[] {"id2", "Item N2"});
+			table.Rows.Add(new object[] {"id3", "Item N3"});
+			
+			TestDataList dl = new TestDataList ();
+			dl.DataKeyField = "id";
+			dl.DataSource = table;
+			dl.DataBind ();
+
+			Assert.AreEqual (null, dl.SelectedValue, "A1");
+			dl.SelectedIndex = 0;
+			Assert.AreEqual ("id1", dl.SelectedValue.ToString (), "A2");
+		}		
+
 		[Test]
 		[ExpectedException (typeof (InvalidOperationException))]
 		public void SelectedValue_WithoutDataKeyField ()