Răsfoiți Sursa

2006-01-24 Gonzalo Paniagua Javier <[email protected]>

	* ListControl.cs: bound checking for Items when loading the control
	state, as the number might have been changed on the fly. Patch by
	Elliott Draper.


svn path=/trunk/mcs/; revision=56007
Gonzalo Paniagua Javier 20 ani în urmă
părinte
comite
fe3850a309

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

@@ -1,3 +1,9 @@
+2006-01-24 Gonzalo Paniagua Javier <[email protected]>
+
+	* ListControl.cs: bound checking for Items when loading the control
+	state, as the number might have been changed on the fly. Patch by
+	Elliott Draper.
+
 2006-01-22  Chris Toshok  <[email protected]>
 
 	* CheckBox.cs: s/GetPostBackClientEvent/GetPostBackEventReference.

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

@@ -331,8 +331,11 @@ namespace System.Web.UI.WebControls {
 			base.LoadControlState (first);
 
 			if (indices != null) {
-				foreach (int index in indices)
-					Items [index].Selected = true;
+				int count = Items.Count;
+				foreach (int index in indices) {
+					if (index >= 0 && index < count)
+						Items [index].Selected = true;
+				}
 			}
 		}
 #endif