Преглед изворни кода

2010-04-13 Marek Habersack <[email protected]>

    	* ImageField.cs, CheckBoxField.cs: OnDataBindField must expect
    	sender to be something else than DataControlFieldCell. Fixes bug
    	#595568

    2010-04-13  Marek Habersack  <[email protected]>

    	* CheckBoxFieldTest.cs: added test for bug #595568

svn path=/trunk/mcs/; revision=155270
Marek Habersack пре 15 година
родитељ
комит
934829dadd

+ 9 - 2
mcs/class/System.Web/Makefile

@@ -76,7 +76,8 @@ RESOURCE_FILES_2 = \
 OTHER_RES = $(RESOURCE_FILES_1)
 TEST_APP_CODE_FILES = \
 	Test/mainsoft/NunitWebResources/App_Code/EnumConverterControl.cs \
-	Test/mainsoft/NunitWebResources/App_Code/MyContainer.cs
+	Test/mainsoft/NunitWebResources/App_Code/MyContainer.cs \
+	Test/mainsoft/NunitWebResources/App_Code/CustomCheckBoxColumn.cs
 
 TEST_APP_GLOBALRESOURCES_FILES = \
 	Test/mainsoft/NunitWebResources/App_GlobalResources/Common.resx \
@@ -215,7 +216,13 @@ TEST_RESOURCE_FILES = \
 	Test/mainsoft/NunitWebResources/SqlDataSource_OnInit_Bug572781.aspx \
 	Test/mainsoft/NunitWebResources/FormViewPagerVisibility.aspx \
 	Test/mainsoft/NunitWebResources/OverridenControlsPropertyAndPostBack_Bug594238.aspx \
-	Test/mainsoft/NunitWebResources/GlobalizationEncodingName.aspx
+	Test/mainsoft/NunitWebResources/GlobalizationEncodingName.aspx \
+	Test/mainsoft/NunitWebResources/CheckBoxField_Bug595568_0.aspx \
+	Test/mainsoft/NunitWebResources/CheckBoxField_Bug595568_1.aspx \
+	Test/mainsoft/NunitWebResources/CheckBoxField_Bug595568_2.aspx \
+	Test/mainsoft/NunitWebResources/CheckBoxField_Bug595568_5.aspx \
+	Test/mainsoft/NunitWebResources/CheckBoxField_Bug595568_6.aspx \
+	Test/mainsoft/NunitWebResources/CheckBoxField_Bug595568_7.aspx
 
 RESX_DIST =  resources/TranslationResources.resx
 ifneq (1, $(FRAMEWORK_VERSION_MAJOR))

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

@@ -1,3 +1,9 @@
+2010-04-13  Marek Habersack  <[email protected]>
+
+	* ImageField.cs, CheckBoxField.cs: OnDataBindField must expect
+	sender to be something else than DataControlFieldCell. Fixes bug
+	#595568
+
 2010-04-07  Marek Habersack  <[email protected]>
 
 	* FormParameter.cs, CookieParameter.cs, ProfileParameter.cs,

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

@@ -121,9 +121,24 @@ namespace System.Web.UI.WebControls {
 		protected override void OnDataBindField (object sender, EventArgs e)
 		{
 			try {
-				DataControlFieldCell cell = (DataControlFieldCell) sender;
-				CheckBox box = (CheckBox) cell.Controls [0];
-				object val = GetValue (cell.BindingContainer);
+				Control container = (Control) sender;
+				object val = GetValue (container.NamingContainer);
+				CheckBox box = sender as CheckBox;
+				if (box == null) {
+					DataControlFieldCell cell = sender as DataControlFieldCell;
+					if (cell != null) {
+						ControlCollection controls = cell.Controls;
+						int ccount = controls != null ? controls.Count : 0;
+						if (ccount == 1)
+							box = controls [0] as CheckBox;
+						if (box == null)
+							return;
+					}
+				}
+				
+				if (box == null)
+					throw new HttpException ("CheckBox field '" + DataField + "' contains a control that isn't a CheckBox.  Override OnDataBindField to inherit from CheckBoxField and add different controls.");
+				
 				if (val != null && val != DBNull.Value)
 					box.Checked = (bool) val;
 				else
@@ -134,11 +149,9 @@ namespace System.Web.UI.WebControls {
 
 				if (!box.Visible)
 					box.Visible = true;
-			}
-			catch (HttpException) {
+			} catch (HttpException) {
 				throw;
-			}
-			catch (Exception ex) {
+			} catch (Exception ex) {
 				throw new HttpException (ex.Message, ex);
 			}
 		}

+ 24 - 12
mcs/class/System.Web/System.Web.UI.WebControls/ImageField.cs

@@ -285,10 +285,15 @@ namespace System.Web.UI.WebControls {
 		
 		PropertyDescriptor GetProperty (Control controlContainer, string fieldName)
 		{
+			if (fieldName == ThisExpression)
+				return null;
+			
 			IDataItemContainer dic = (IDataItemContainer) controlContainer;
-			PropertyDescriptor prop = TypeDescriptor.GetProperties (dic.DataItem) [fieldName];
+			PropertyDescriptorCollection properties = TypeDescriptor.GetProperties (dic.DataItem);
+			PropertyDescriptor prop = properties != null ? properties [fieldName] : null;
 			if (prop == null)
 				throw new InvalidOperationException ("Property '" + fieldName + "' not found in object of type " + dic.DataItem.GetType());
+			
 			return prop;
 		}
 		
@@ -299,34 +304,41 @@ namespace System.Web.UI.WebControls {
 		
 		protected virtual void OnDataBindField (object sender, EventArgs e)
 		{
-			DataControlFieldCell cell = (DataControlFieldCell) sender;
-
-			if (cell.Controls.Count == 0)
+			Control control = (Control) sender;
+			ControlCollection controls = control != null ? control.Controls : null;
+			Control namingContainer = control.NamingContainer;
+			Control c;
+			if (sender is DataControlFieldCell) {
+				if (controls.Count == 0)
+					return;
+				c = controls [0];
+			} else if (sender is Image || sender is TextBox)
+				c = control;
+			else
 				return;
-			
+
 			if (imageProperty == null)
-				imageProperty = GetProperty (cell.BindingContainer, DataImageUrlField);
+				imageProperty = GetProperty (namingContainer, DataImageUrlField);
 			
-			Control c = cell.Controls [0];
 			if (c is TextBox) {
-				object val = GetValue (cell.BindingContainer, DataImageUrlField, ref imageProperty);
-				((TextBox)c).Text = val != null ? val.ToString() : "";
+				object val = GetValue (namingContainer, DataImageUrlField, ref imageProperty);
+				((TextBox)c).Text = val != null ? val.ToString() : String.Empty;
 			}
 			else if (c is Image) {
 				Image img = (Image)c;
-				string value =  FormatImageUrlValue (GetValue (cell.BindingContainer, DataImageUrlField, ref imageProperty));
+				string value =  FormatImageUrlValue (GetValue (namingContainer, DataImageUrlField, ref imageProperty));
 				if (value == null || (ConvertEmptyStringToNull && value.Length == 0)) {
 					if (NullImageUrl == null || NullImageUrl.Length == 0) {
 						c.Visible = false;
 						Label label = new Label ();
 						label.Text = NullDisplayText;
-						cell.Controls.Add (label);
+						controls.Add (label);
 					}
 					else
 						value = NullImageUrl;
 				}
 				img.ImageUrl = value;
-				img.AlternateText = GetFormattedAlternateText (cell.BindingContainer);
+				img.AlternateText = GetFormattedAlternateText (namingContainer);
 			}
 		}
 		

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

@@ -1,3 +1,7 @@
+2010-04-13  Marek Habersack  <[email protected]>
+
+	* CheckBoxFieldTest.cs: added test for bug #595568
+
 2010-04-01  Marek Habersack  <[email protected]>
 
 	* FormViewTest.cs: added test for bug #578863

+ 179 - 2
mcs/class/System.Web/Test/System.Web.UI.WebControls/CheckBoxFieldTest.cs

@@ -43,8 +43,8 @@ using System.Collections.Specialized;
 using NUnit.Framework;
 using System.Data;
 
-
-
+using MonoTests.SystemWeb.Framework;
+using MonoTests.stand_alone.WebHarness;
 
 namespace MonoTests.System.Web.UI.WebControls
 {
@@ -114,6 +114,183 @@ namespace MonoTests.System.Web.UI.WebControls
 		public const string WRONGFIELD = "str";
 		public static int databound;
 
+		[TestFixtureSetUp]
+		public void SetUp ()
+		{
+			WebTest.CopyResource (GetType (), "CheckBoxField_Bug595568_0.aspx", "CheckBoxField_Bug595568_0.aspx");
+			WebTest.CopyResource (GetType (), "CheckBoxField_Bug595568_1.aspx", "CheckBoxField_Bug595568_1.aspx");
+			WebTest.CopyResource (GetType (), "CheckBoxField_Bug595568_2.aspx", "CheckBoxField_Bug595568_2.aspx");
+			WebTest.CopyResource (GetType (), "CheckBoxField_Bug595568_5.aspx", "CheckBoxField_Bug595568_5.aspx");
+			WebTest.CopyResource (GetType (), "CheckBoxField_Bug595568_6.aspx", "CheckBoxField_Bug595568_6.aspx");
+			WebTest.CopyResource (GetType (), "CheckBoxField_Bug595568_7.aspx", "CheckBoxField_Bug595568_7.aspx");
+		}
+
+		[Test (Description="Bug 595568 #0")]
+		public void CheckBoxField_Bug595568_0 ()
+		{
+			string originalHtml = @"<div> 
+	<table id=""gridView"" cellspacing=""0"" rules=""all"" border=""1"" style=""border-collapse:collapse;""> 
+			<tr> 
+				<th scope=""col"">&nbsp;</th> 
+			</tr><tr> 
+				<td><span title=""Dummy""><input id=""gridView_ctl02_ctl00"" type=""checkbox"" name=""gridView$ctl02$ctl00"" checked=""checked"" /></span></td> 
+			</tr><tr> 
+				<td><span title=""Dummy""><input id=""gridView_ctl03_ctl00"" type=""checkbox"" name=""gridView$ctl03$ctl00"" /></span></td> 
+			</tr><tr> 
+				<td><span title=""Dummy""><input id=""gridView_ctl04_ctl00"" type=""checkbox"" name=""gridView$ctl04$ctl00"" /></span></td> 
+			</tr> 
+		</table>
+	</div>";
+			WebTest t = new WebTest ("CheckBoxField_Bug595568_0.aspx");
+			string pageHtml = t.Run ();
+			string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHtml);
+
+			HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "#A1");
+		}
+
+		[Test (Description="Bug 595568 #1")]
+		public void CheckBoxField_Bug595568_1 ()
+		{
+			string originalHtml = @"<div> 
+	<table id=""gridView"" cellspacing=""0"" rules=""all"" border=""1"" style=""border-collapse:collapse;""> 
+			<tr> 
+				<th scope=""col"">&nbsp;</th> 
+			</tr><tr> 
+				<td><select size=""4""> 
+ 
+				</select><span title=""Dummy""><input id=""gridView_ctl02_ctl01"" type=""checkbox"" name=""gridView$ctl02$ctl01"" checked=""checked"" /></span></td> 
+			</tr><tr> 
+				<td><select size=""4""> 
+ 
+				</select><span title=""Dummy""><input id=""gridView_ctl03_ctl01"" type=""checkbox"" name=""gridView$ctl03$ctl01"" /></span></td> 
+			</tr><tr> 
+				<td><select size=""4""> 
+ 
+				</select><span title=""Dummy""><input id=""gridView_ctl04_ctl01"" type=""checkbox"" name=""gridView$ctl04$ctl01"" /></span></td> 
+			</tr> 
+		</table> 
+	</div>";
+			WebTest t = new WebTest ("CheckBoxField_Bug595568_1.aspx");
+			string pageHtml = t.Run ();
+			string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHtml);
+
+			HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "#A1");
+		}
+
+		[Test (Description="Bug 595568 #2")]
+		public void CheckBoxField_Bug595568_2 ()
+		{
+			string originalHtml = @"<div> 
+	<table id=""gridView"" cellspacing=""0"" rules=""all"" border=""1"" style=""border-collapse:collapse;""> 
+			<tr> 
+				<th scope=""col"">&nbsp;</th> 
+			</tr><tr> 
+				<td><input id=""gridView_ctl02_ctl00"" type=""checkbox"" name=""gridView$ctl02$ctl00"" /><span title=""Dummy""><input id=""gridView_ctl02_ctl01"" type=""checkbox"" name=""gridView$ctl02$ctl01"" checked=""checked"" /></span><input id=""gridView_ctl02_ctl02"" type=""checkbox"" name=""gridView$ctl02$ctl02"" /></td> 
+			</tr><tr> 
+				<td><input id=""gridView_ctl03_ctl00"" type=""checkbox"" name=""gridView$ctl03$ctl00"" /><span title=""Dummy""><input id=""gridView_ctl03_ctl01"" type=""checkbox"" name=""gridView$ctl03$ctl01"" /></span><input id=""gridView_ctl03_ctl02"" type=""checkbox"" name=""gridView$ctl03$ctl02"" /></td> 
+			</tr><tr> 
+				<td><input id=""gridView_ctl04_ctl00"" type=""checkbox"" name=""gridView$ctl04$ctl00"" /><span title=""Dummy""><input id=""gridView_ctl04_ctl01"" type=""checkbox"" name=""gridView$ctl04$ctl01"" /></span><input id=""gridView_ctl04_ctl02"" type=""checkbox"" name=""gridView$ctl04$ctl02"" /></td> 
+			</tr> 
+		</table> 
+	</div>";
+			
+			WebTest t = new WebTest ("CheckBoxField_Bug595568_2.aspx");
+			string pageHtml = t.Run ();
+			string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHtml);
+
+			HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "#A1");
+		}
+
+		[Test (Description="Bug 595568 #5")]
+		public void CheckBoxField_Bug595568_5 ()
+		{
+			string originalHtml = @"<div> 
+	<table id=""gridView"" cellspacing=""0"" rules=""all"" border=""1"" style=""border-collapse:collapse;""> 
+			<tr> 
+				<th scope=""col"">&nbsp;</th> 
+			</tr><tr> 
+				<td><select size=""4""> 
+ 
+				</select></td> 
+			</tr><tr> 
+				<td><select size=""4""> 
+ 
+				</select></td> 
+			</tr><tr> 
+				<td><select size=""4""> 
+ 
+				</select></td> 
+			</tr> 
+		</table> 
+	</div>";
+
+			WebTest t = new WebTest ("CheckBoxField_Bug595568_5.aspx");
+			string pageHtml = t.Run ();
+			string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHtml);
+
+			HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "#A1");
+		}
+		
+		[Test (Description="Bug 595568 #6")]
+		public void CheckBoxField_Bug595568_6 ()
+		{	
+			string originalHtml = @"<div> 
+	<table id=""gridView"" cellspacing=""0"" rules=""all"" border=""1"" style=""border-collapse:collapse;""> 
+			<tr> 
+				<th scope=""col"">&nbsp;</th> 
+			</tr><tr> 
+				<td><select size=""4""> 
+ 
+				</select><input id=""gridView_ctl02_ctl01"" type=""checkbox"" name=""gridView$ctl02$ctl01"" /></td> 
+			</tr><tr> 
+				<td><select size=""4""> 
+ 
+				</select><input id=""gridView_ctl03_ctl01"" type=""checkbox"" name=""gridView$ctl03$ctl01"" /></td> 
+			</tr><tr> 
+				<td><select size=""4""> 
+ 
+				</select><input id=""gridView_ctl04_ctl01"" type=""checkbox"" name=""gridView$ctl04$ctl01"" /></td> 
+			</tr> 
+		</table> 
+	</div>";
+
+			WebTest t = new WebTest ("CheckBoxField_Bug595568_6.aspx");
+			string pageHtml = t.Run ();
+			string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHtml);
+
+			HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "#A1");
+		}
+
+		[Test (Description="Bug 595568 #7")]
+		public void CheckBoxField_Bug595568_7 ()
+		{
+			string originalHtml = @"<div> 
+	<table id=""gridView"" cellspacing=""0"" rules=""all"" border=""1"" style=""border-collapse:collapse;""> 
+			<tr> 
+				<th scope=""col"">&nbsp;</th> 
+			</tr><tr> 
+				<td><input id=""gridView_ctl02_ctl00"" type=""checkbox"" name=""gridView$ctl02$ctl00"" /><select size=""4""> 
+ 
+				</select></td> 
+			</tr><tr> 
+				<td><input id=""gridView_ctl03_ctl00"" type=""checkbox"" name=""gridView$ctl03$ctl00"" /><select size=""4""> 
+ 
+				</select></td> 
+			</tr><tr> 
+				<td><input id=""gridView_ctl04_ctl00"" type=""checkbox"" name=""gridView$ctl04$ctl00"" /><select size=""4""> 
+ 
+				</select></td> 
+			</tr> 
+		</table> 
+	</div>";
+
+			WebTest t = new WebTest ("CheckBoxField_Bug595568_7.aspx");		
+			string pageHtml = t.Run ();
+			string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHtml);
+
+			HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "#A1");
+		}
+		
 		[Test]
 		public void CheckBoxField_DefaultProperty ()
 		{

+ 118 - 0
mcs/class/System.Web/Test/mainsoft/NunitWebResources/App_Code/CustomCheckBoxColumn.cs

@@ -0,0 +1,118 @@
+using System;
+using System.Web;
+using System.Web.UI;
+using System.Web.UI.WebControls;
+
+namespace Tests
+{
+	public class CustomCheckBoxColumn : CheckBoxField
+	{
+		string caseId;
+
+		public CustomCheckBoxColumn (string id)
+		{
+			this.caseId = id;
+		}
+
+		protected override void InitializeDataCell(DataControlFieldCell cell, DataControlRowState rowState)
+		{
+			switch (caseId) {
+				default:
+				case "0":
+					Case0 (cell);
+				break;
+    			
+				case "1":
+					Case1 (cell);
+					break;
+    			
+				case "2":
+					Case2 (cell);
+					break;
+    			
+				case "3":
+					Case3 (cell);
+					break;
+    		
+				case "4":
+					Case4 (cell);
+					break;
+    		
+				case "5":
+					Case5 (cell);
+					break;
+    		
+				case "6":
+					Case6 (cell);
+					break;
+    		
+				case "7":
+					Case7 (cell);
+					break;
+			}
+		}
+    	
+		void Case0 (DataControlFieldCell cell)
+		{
+			CheckBox checkBox = new CheckBox();
+			checkBox.ToolTip = "Dummy";
+			cell.Controls.Add(checkBox);
+			checkBox.DataBinding += OnDataBindField;
+		}
+        
+		void Case1 (DataControlFieldCell cell)
+		{
+			ListBox lb = new ListBox ();
+			cell.Controls.Add(lb);
+			Case0 (cell);
+		}
+        
+		void Case2 (DataControlFieldCell cell)
+		{
+			cell.Controls.Add(new CheckBox ());
+			Case0 (cell);
+			cell.Controls.Add(new CheckBox ());
+		}
+        
+		void Case3 (DataControlFieldCell cell)
+		{
+			Content content = new Content ();
+    	    
+			CheckBox checkBox = new CheckBox();
+			checkBox.ToolTip = "Dummy";
+			content.Controls.Add(checkBox);
+			checkBox.DataBinding += OnDataBindField;
+            
+			cell.Controls.Add (content);
+		}
+        
+		void Case4 (DataControlFieldCell cell)
+		{
+			CheckBox checkBox = new CheckBox();
+			checkBox.ToolTip = "Dummy";
+			cell.Controls.Add(checkBox);
+            
+			ListBox lb = new ListBox ();
+			lb.DataBinding += OnDataBindField;
+			cell.Controls.Add(lb);
+		}
+        
+		void Case5 (DataControlFieldCell cell)
+		{
+			cell.Controls.Add (new ListBox ());
+		}
+    	
+		void Case6 (DataControlFieldCell cell)
+		{
+			cell.Controls.Add (new ListBox ());
+			cell.Controls.Add (new CheckBox ());
+		}
+    	
+		void Case7 (DataControlFieldCell cell)
+		{
+			cell.Controls.Add (new CheckBox ());
+			cell.Controls.Add (new ListBox ());
+		}
+	}
+}
+

+ 35 - 0
mcs/class/System.Web/Test/mainsoft/NunitWebResources/CheckBoxField_Bug595568_0.aspx

@@ -0,0 +1,35 @@
+<%@ Page Language="C#" AutoEventWireup="true" CodeFile="MyPage.aspx.cs" Inherits="MyPage" %>
+<%@ Import Namespace="Tests" %>
+
+<script runat="server">
+    protected void Page_Load(object sender, EventArgs e)
+    {
+        if (IsPostBack) return;
+        
+        bool[] ba = new bool [3];
+        ba [0] = true;
+        gridView.DataSource = ba;
+        gridView.DataBind();
+    }
+
+    protected void OnGridViewInit(object sender, EventArgs e)
+    {
+        CustomCheckBoxColumn column = new CustomCheckBoxColumn("0");
+        column.DataField = "!";
+        gridView.Columns.Add(column);
+    }
+</script>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head runat="server">
+    <title></title>
+</head>
+<body>
+    <form id="form1" method="GET" runat="server">
+    <div>
+        <%= MonoTests.stand_alone.WebHarness.HtmlDiff.BEGIN_TAG %><asp:GridView runat="server" ID="gridView" OnInit="OnGridViewInit" AutoGenerateColumns="False" /><%= MonoTests.stand_alone.WebHarness.HtmlDiff.END_TAG %>
+    </div>
+    </form>
+</body>
+</html>

+ 35 - 0
mcs/class/System.Web/Test/mainsoft/NunitWebResources/CheckBoxField_Bug595568_1.aspx

@@ -0,0 +1,35 @@
+<%@ Page Language="C#" AutoEventWireup="true" CodeFile="MyPage.aspx.cs" Inherits="MyPage" %>
+<%@ Import Namespace="Tests" %>
+
+<script runat="server">
+    protected void Page_Load(object sender, EventArgs e)
+    {
+        if (IsPostBack) return;
+        
+        bool[] ba = new bool [3];
+        ba [0] = true;
+        gridView.DataSource = ba;
+        gridView.DataBind();
+    }
+
+    protected void OnGridViewInit(object sender, EventArgs e)
+    {
+        CustomCheckBoxColumn column = new CustomCheckBoxColumn("1");
+        column.DataField = "!";
+        gridView.Columns.Add(column);
+    }
+</script>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head runat="server">
+    <title></title>
+</head>
+<body>
+    <form id="form1" method="GET" runat="server">
+    <div>
+        <%= MonoTests.stand_alone.WebHarness.HtmlDiff.BEGIN_TAG %><asp:GridView runat="server" ID="gridView" OnInit="OnGridViewInit" AutoGenerateColumns="False" /><%= MonoTests.stand_alone.WebHarness.HtmlDiff.END_TAG %>
+    </div>
+    </form>
+</body>
+</html>

+ 35 - 0
mcs/class/System.Web/Test/mainsoft/NunitWebResources/CheckBoxField_Bug595568_2.aspx

@@ -0,0 +1,35 @@
+<%@ Page Language="C#" AutoEventWireup="true" CodeFile="MyPage.aspx.cs" Inherits="MyPage" %>
+<%@ Import Namespace="Tests" %>
+
+<script runat="server">
+    protected void Page_Load(object sender, EventArgs e)
+    {
+        if (IsPostBack) return;
+        
+        bool[] ba = new bool [3];
+        ba [0] = true;
+        gridView.DataSource = ba;
+        gridView.DataBind();
+    }
+
+    protected void OnGridViewInit(object sender, EventArgs e)
+    {
+        CustomCheckBoxColumn column = new CustomCheckBoxColumn("2");
+        column.DataField = "!";
+        gridView.Columns.Add(column);
+    }
+</script>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head runat="server">
+    <title></title>
+</head>
+<body>
+    <form id="form1" method="GET" runat="server">
+    <div>
+        <%= MonoTests.stand_alone.WebHarness.HtmlDiff.BEGIN_TAG %><asp:GridView runat="server" ID="gridView" OnInit="OnGridViewInit" AutoGenerateColumns="False" /><%= MonoTests.stand_alone.WebHarness.HtmlDiff.END_TAG %>
+    </div>
+    </form>
+</body>
+</html>

+ 35 - 0
mcs/class/System.Web/Test/mainsoft/NunitWebResources/CheckBoxField_Bug595568_5.aspx

@@ -0,0 +1,35 @@
+<%@ Page Language="C#" AutoEventWireup="true" CodeFile="MyPage.aspx.cs" Inherits="MyPage" %>
+<%@ Import Namespace="Tests" %>
+
+<script runat="server">
+    protected void Page_Load(object sender, EventArgs e)
+    {
+        if (IsPostBack) return;
+        
+        bool[] ba = new bool [3];
+        ba [0] = true;
+        gridView.DataSource = ba;
+        gridView.DataBind();
+    }
+
+    protected void OnGridViewInit(object sender, EventArgs e)
+    {
+        CustomCheckBoxColumn column = new CustomCheckBoxColumn("5");
+        column.DataField = "!";
+        gridView.Columns.Add(column);
+    }
+</script>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head runat="server">
+    <title></title>
+</head>
+<body>
+    <form id="form1" method="GET" runat="server">
+    <div>
+        <%= MonoTests.stand_alone.WebHarness.HtmlDiff.BEGIN_TAG %><asp:GridView runat="server" ID="gridView" OnInit="OnGridViewInit" AutoGenerateColumns="False" /><%= MonoTests.stand_alone.WebHarness.HtmlDiff.END_TAG %>
+    </div>
+    </form>
+</body>
+</html>

+ 35 - 0
mcs/class/System.Web/Test/mainsoft/NunitWebResources/CheckBoxField_Bug595568_6.aspx

@@ -0,0 +1,35 @@
+<%@ Page Language="C#" AutoEventWireup="true" CodeFile="MyPage.aspx.cs" Inherits="MyPage" %>
+<%@ Import Namespace="Tests" %>
+
+<script runat="server">
+    protected void Page_Load(object sender, EventArgs e)
+    {
+        if (IsPostBack) return;
+        
+        bool[] ba = new bool [3];
+        ba [0] = true;
+        gridView.DataSource = ba;
+        gridView.DataBind();
+    }
+
+    protected void OnGridViewInit(object sender, EventArgs e)
+    {
+        CustomCheckBoxColumn column = new CustomCheckBoxColumn("6");
+        column.DataField = "!";
+        gridView.Columns.Add(column);
+    }
+</script>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head runat="server">
+    <title></title>
+</head>
+<body>
+    <form id="form1" method="GET" runat="server">
+    <div>
+        <%= MonoTests.stand_alone.WebHarness.HtmlDiff.BEGIN_TAG %><asp:GridView runat="server" ID="gridView" OnInit="OnGridViewInit" AutoGenerateColumns="False" /><%= MonoTests.stand_alone.WebHarness.HtmlDiff.END_TAG %>
+    </div>
+    </form>
+</body>
+</html>

+ 35 - 0
mcs/class/System.Web/Test/mainsoft/NunitWebResources/CheckBoxField_Bug595568_7.aspx

@@ -0,0 +1,35 @@
+<%@ Page Language="C#" AutoEventWireup="true" CodeFile="MyPage.aspx.cs" Inherits="MyPage" %>
+<%@ Import Namespace="Tests" %>
+
+<script runat="server">
+    protected void Page_Load(object sender, EventArgs e)
+    {
+        if (IsPostBack) return;
+        
+        bool[] ba = new bool [3];
+        ba [0] = true;
+        gridView.DataSource = ba;
+        gridView.DataBind();
+    }
+
+    protected void OnGridViewInit(object sender, EventArgs e)
+    {
+        CustomCheckBoxColumn column = new CustomCheckBoxColumn("7");
+        column.DataField = "!";
+        gridView.Columns.Add(column);
+    }
+</script>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head runat="server">
+    <title></title>
+</head>
+<body>
+    <form id="form1" method="GET" runat="server">
+    <div>
+        <%= MonoTests.stand_alone.WebHarness.HtmlDiff.BEGIN_TAG %><asp:GridView runat="server" ID="gridView" OnInit="OnGridViewInit" AutoGenerateColumns="False" /><%= MonoTests.stand_alone.WebHarness.HtmlDiff.END_TAG %>
+    </div>
+    </form>
+</body>
+</html>