CheckBoxFieldTest.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  1. //
  2. // Tests for System.Web.UI.WebControls.CheckBoxFieldTest.cs
  3. //
  4. // Author:
  5. // Yoni Klein ([email protected])
  6. //
  7. //
  8. // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
  9. //
  10. // Permission is hereby granted, free of charge, to any person obtaining
  11. // a copy of this software and associated documentation files (the
  12. // "Software"), to deal in the Software without restriction, including
  13. // without limitation the rights to use, copy, modify, merge, publish,
  14. // distribute, sublicense, and/or sell copies of the Software, and to
  15. // permit persons to whom the Software is furnished to do so, subject to
  16. // the following conditions:
  17. //
  18. // The above copyright notice and this permission notice shall be
  19. // included in all copies or substantial portions of the Software.
  20. //
  21. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  22. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  23. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  24. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  25. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  26. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  27. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  28. using System;
  29. using System.Collections.Generic;
  30. using System.Text;
  31. using System.Web;
  32. using System.Web.UI;
  33. using System.Web.UI.WebControls;
  34. using System.IO;
  35. using System.Drawing;
  36. using System.Collections;
  37. using System.Collections.Specialized;
  38. using NUnit.Framework;
  39. using System.Data;
  40. using MonoTests.SystemWeb.Framework;
  41. using MonoTests.stand_alone.WebHarness;
  42. namespace MonoTests.System.Web.UI.WebControls
  43. {
  44. class PokerCheckBoxField : CheckBoxField
  45. {
  46. // View state Stuff
  47. public PokerCheckBoxField ()
  48. : base ()
  49. {
  50. TrackViewState ();
  51. }
  52. public object SaveState ()
  53. {
  54. return SaveViewState ();
  55. }
  56. public void LoadState (object o)
  57. {
  58. LoadViewState (o);
  59. }
  60. public StateBag StateBag
  61. {
  62. get { return base.ViewState; }
  63. }
  64. public bool GetSupportsHtmlEncode
  65. {
  66. get
  67. {
  68. return base.SupportsHtmlEncode;
  69. }
  70. }
  71. public void DoCopyProperties (DataControlField newField)
  72. {
  73. base.CopyProperties (newField);
  74. }
  75. public DataControlField DoCreateField ()
  76. {
  77. return base.CreateField ();
  78. }
  79. public object DoGetDesignTimeValue ()
  80. {
  81. return base.GetDesignTimeValue ();
  82. }
  83. public void DoInitializeDataCell (DataControlFieldCell cell, DataControlRowState rowState)
  84. {
  85. this.InitializeDataCell (cell, rowState);
  86. }
  87. protected override void OnDataBindField (object sender, EventArgs e)
  88. {
  89. base.OnDataBindField (sender, e);
  90. CheckBoxFieldTest.databound += 1;
  91. }
  92. }
  93. [TestFixture]
  94. public class CheckBoxFieldTest
  95. {
  96. public const string FIELDNAME = "checkbox";
  97. public const string WRONGFIELD = "str";
  98. public static int databound;
  99. [TestFixtureSetUp]
  100. public void SetUp ()
  101. {
  102. WebTest.CopyResource (GetType (), "CheckBoxField_Bug595568_0.aspx", "CheckBoxField_Bug595568_0.aspx");
  103. WebTest.CopyResource (GetType (), "CheckBoxField_Bug595568_1.aspx", "CheckBoxField_Bug595568_1.aspx");
  104. WebTest.CopyResource (GetType (), "CheckBoxField_Bug595568_2.aspx", "CheckBoxField_Bug595568_2.aspx");
  105. WebTest.CopyResource (GetType (), "CheckBoxField_Bug595568_5.aspx", "CheckBoxField_Bug595568_5.aspx");
  106. WebTest.CopyResource (GetType (), "CheckBoxField_Bug595568_6.aspx", "CheckBoxField_Bug595568_6.aspx");
  107. WebTest.CopyResource (GetType (), "CheckBoxField_Bug595568_7.aspx", "CheckBoxField_Bug595568_7.aspx");
  108. }
  109. [Test (Description="Bug 595568 #0")]
  110. public void CheckBoxField_Bug595568_0 ()
  111. {
  112. string originalHtml = "<div>\r\n\t<table cellspacing=\"0\" rules=\"all\" border=\"1\" id=\"gridView\" style=\"border-collapse:collapse;\">\r\n\t\t<tr>\r\n\t\t\t<th scope=\"col\">&nbsp;</th>\r\n\t\t</tr><tr>\r\n\t\t\t<td><span title=\"Dummy\"><input id=\"gridView_ctl00_0\" type=\"checkbox\" name=\"gridView$ctl02$ctl00\" checked=\"checked\" /></span></td>\r\n\t\t</tr><tr>\r\n\t\t\t<td><span title=\"Dummy\"><input id=\"gridView_ctl00_1\" type=\"checkbox\" name=\"gridView$ctl03$ctl00\" /></span></td>\r\n\t\t</tr><tr>\r\n\t\t\t<td><span title=\"Dummy\"><input id=\"gridView_ctl00_2\" type=\"checkbox\" name=\"gridView$ctl04$ctl00\" /></span></td>\r\n\t\t</tr>\r\n\t</table>\r\n</div>";
  113. WebTest t = new WebTest ("CheckBoxField_Bug595568_0.aspx");
  114. string pageHtml = t.Run ();
  115. string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHtml);
  116. HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "#A1");
  117. }
  118. [Test (Description="Bug 595568 #1")]
  119. public void CheckBoxField_Bug595568_1 ()
  120. {
  121. string originalHtml = "<div>\r\n\t<table cellspacing=\"0\" rules=\"all\" border=\"1\" id=\"gridView\" style=\"border-collapse:collapse;\">\r\n\t\t<tr>\r\n\t\t\t<th scope=\"col\">&nbsp;</th>\r\n\t\t</tr><tr>\r\n\t\t\t<td><select size=\"4\" name=\"gridView$ctl02$ctl00\">\r\n\r\n\t\t\t</select><span title=\"Dummy\"><input id=\"gridView_ctl01_0\" type=\"checkbox\" name=\"gridView$ctl02$ctl01\" checked=\"checked\" /></span></td>\r\n\t\t</tr><tr>\r\n\t\t\t<td><select size=\"4\" name=\"gridView$ctl03$ctl00\">\r\n\r\n\t\t\t</select><span title=\"Dummy\"><input id=\"gridView_ctl01_1\" type=\"checkbox\" name=\"gridView$ctl03$ctl01\" /></span></td>\r\n\t\t</tr><tr>\r\n\t\t\t<td><select size=\"4\" name=\"gridView$ctl04$ctl00\">\r\n\r\n\t\t\t</select><span title=\"Dummy\"><input id=\"gridView_ctl01_2\" type=\"checkbox\" name=\"gridView$ctl04$ctl01\" /></span></td>\r\n\t\t</tr>\r\n\t</table>\r\n</div>";
  122. WebTest t = new WebTest ("CheckBoxField_Bug595568_1.aspx");
  123. string pageHtml = t.Run ();
  124. string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHtml);
  125. HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "#A1");
  126. }
  127. [Test (Description="Bug 595568 #2")]
  128. public void CheckBoxField_Bug595568_2 ()
  129. {
  130. string originalHtml = "<div>\r\n\t<table cellspacing=\"0\" rules=\"all\" border=\"1\" id=\"gridView\" style=\"border-collapse:collapse;\">\r\n\t\t<tr>\r\n\t\t\t<th scope=\"col\">&nbsp;</th>\r\n\t\t</tr><tr>\r\n\t\t\t<td><input id=\"gridView_ctl00_0\" type=\"checkbox\" name=\"gridView$ctl02$ctl00\" /><span title=\"Dummy\"><input id=\"gridView_ctl01_0\" type=\"checkbox\" name=\"gridView$ctl02$ctl01\" checked=\"checked\" /></span><input id=\"gridView_ctl02_0\" type=\"checkbox\" name=\"gridView$ctl02$ctl02\" /></td>\r\n\t\t</tr><tr>\r\n\t\t\t<td><input id=\"gridView_ctl00_1\" type=\"checkbox\" name=\"gridView$ctl03$ctl00\" /><span title=\"Dummy\"><input id=\"gridView_ctl01_1\" type=\"checkbox\" name=\"gridView$ctl03$ctl01\" /></span><input id=\"gridView_ctl02_1\" type=\"checkbox\" name=\"gridView$ctl03$ctl02\" /></td>\r\n\t\t</tr><tr>\r\n\t\t\t<td><input id=\"gridView_ctl00_2\" type=\"checkbox\" name=\"gridView$ctl04$ctl00\" /><span title=\"Dummy\"><input id=\"gridView_ctl01_2\" type=\"checkbox\" name=\"gridView$ctl04$ctl01\" /></span><input id=\"gridView_ctl02_2\" type=\"checkbox\" name=\"gridView$ctl04$ctl02\" /></td>\r\n\t\t</tr>\r\n\t</table>\r\n</div>";
  131. WebTest t = new WebTest ("CheckBoxField_Bug595568_2.aspx");
  132. string pageHtml = t.Run ();
  133. string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHtml);
  134. HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "#A1");
  135. }
  136. [Test (Description="Bug 595568 #5")]
  137. public void CheckBoxField_Bug595568_5 ()
  138. {
  139. string originalHtml = "<div>\r\n\t<table cellspacing=\"0\" rules=\"all\" border=\"1\" id=\"gridView\" style=\"border-collapse:collapse;\">\r\n\t\t<tr>\r\n\t\t\t<th scope=\"col\">&nbsp;</th>\r\n\t\t</tr><tr>\r\n\t\t\t<td><select size=\"4\" name=\"gridView$ctl02$ctl00\">\r\n\r\n\t\t\t</select></td>\r\n\t\t</tr><tr>\r\n\t\t\t<td><select size=\"4\" name=\"gridView$ctl03$ctl00\">\r\n\r\n\t\t\t</select></td>\r\n\t\t</tr><tr>\r\n\t\t\t<td><select size=\"4\" name=\"gridView$ctl04$ctl00\">\r\n\r\n\t\t\t</select></td>\r\n\t\t</tr>\r\n\t</table>\r\n</div>";
  140. WebTest t = new WebTest ("CheckBoxField_Bug595568_5.aspx");
  141. string pageHtml = t.Run ();
  142. string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHtml);
  143. HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "#A1");
  144. }
  145. [Test (Description="Bug 595568 #6")]
  146. public void CheckBoxField_Bug595568_6 ()
  147. {
  148. string originalHtml = "<div>\r\n\t<table cellspacing=\"0\" rules=\"all\" border=\"1\" id=\"gridView\" style=\"border-collapse:collapse;\">\r\n\t\t<tr>\r\n\t\t\t<th scope=\"col\">&nbsp;</th>\r\n\t\t</tr><tr>\r\n\t\t\t<td><select size=\"4\" name=\"gridView$ctl02$ctl00\">\r\n\r\n\t\t\t</select><input id=\"gridView_ctl01_0\" type=\"checkbox\" name=\"gridView$ctl02$ctl01\" /></td>\r\n\t\t</tr><tr>\r\n\t\t\t<td><select size=\"4\" name=\"gridView$ctl03$ctl00\">\r\n\r\n\t\t\t</select><input id=\"gridView_ctl01_1\" type=\"checkbox\" name=\"gridView$ctl03$ctl01\" /></td>\r\n\t\t</tr><tr>\r\n\t\t\t<td><select size=\"4\" name=\"gridView$ctl04$ctl00\">\r\n\r\n\t\t\t</select><input id=\"gridView_ctl01_2\" type=\"checkbox\" name=\"gridView$ctl04$ctl01\" /></td>\r\n\t\t</tr>\r\n\t</table>\r\n</div>";
  149. WebTest t = new WebTest ("CheckBoxField_Bug595568_6.aspx");
  150. string pageHtml = t.Run ();
  151. string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHtml);
  152. HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "#A1");
  153. }
  154. [Test (Description="Bug 595568 #7")]
  155. public void CheckBoxField_Bug595568_7 ()
  156. {
  157. string originalHtml = "<div>\r\n\t<table cellspacing=\"0\" rules=\"all\" border=\"1\" id=\"gridView\" style=\"border-collapse:collapse;\">\r\n\t\t<tr>\r\n\t\t\t<th scope=\"col\">&nbsp;</th>\r\n\t\t</tr><tr>\r\n\t\t\t<td><input id=\"gridView_ctl00_0\" type=\"checkbox\" name=\"gridView$ctl02$ctl00\" /><select size=\"4\" name=\"gridView$ctl02$ctl01\">\r\n\r\n\t\t\t</select></td>\r\n\t\t</tr><tr>\r\n\t\t\t<td><input id=\"gridView_ctl00_1\" type=\"checkbox\" name=\"gridView$ctl03$ctl00\" /><select size=\"4\" name=\"gridView$ctl03$ctl01\">\r\n\r\n\t\t\t</select></td>\r\n\t\t</tr><tr>\r\n\t\t\t<td><input id=\"gridView_ctl00_2\" type=\"checkbox\" name=\"gridView$ctl04$ctl00\" /><select size=\"4\" name=\"gridView$ctl04$ctl01\">\r\n\r\n\t\t\t</select></td>\r\n\t\t</tr>\r\n\t</table>\r\n</div>";
  158. WebTest t = new WebTest ("CheckBoxField_Bug595568_7.aspx");
  159. string pageHtml = t.Run ();
  160. string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHtml);
  161. HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "#A1");
  162. }
  163. [Test]
  164. public void CheckBoxField_DefaultProperty ()
  165. {
  166. PokerCheckBoxField field = new PokerCheckBoxField ();
  167. Assert.AreEqual ("", field.DataField, "DataField");
  168. Assert.AreEqual ("", field.Text, "Text");
  169. Assert.AreEqual (false, field.GetSupportsHtmlEncode, "SupportsHtmlEncode");
  170. }
  171. [Test]
  172. public void CheckBoxField_AssignProperty ()
  173. {
  174. PokerCheckBoxField field = new PokerCheckBoxField ();
  175. field.DataField = "test";
  176. Assert.AreEqual ("test", field.DataField, "DataField");
  177. field.Text = "test";
  178. Assert.AreEqual ("test", field.Text, "Text");
  179. }
  180. public void CheckBoxField_ExtractValuesFromCell ()
  181. {
  182. PokerCheckBoxField field = new PokerCheckBoxField ();
  183. OrderedDictionary dictionary = new OrderedDictionary ();
  184. DataControlFieldCell cell = new DataControlFieldCell (null);
  185. cell.Controls.Add (new CheckBox ());
  186. field.ExtractValuesFromCell (dictionary, cell, DataControlRowState.Normal, true);
  187. Assert.AreEqual (1, dictionary.Count, "ExtractValuesFromCellCount#1");
  188. Assert.AreEqual ("False", dictionary[0].ToString (), "ExtractValuesFromCellValueFalse");
  189. CheckBox cb = new CheckBox ();
  190. cb.Checked = true;
  191. cell.Controls.Clear ();
  192. cell.Controls.Add (cb);
  193. field.ExtractValuesFromCell (dictionary, cell, DataControlRowState.Normal, true);
  194. Assert.AreEqual (1, dictionary.Count, "ExtractValuesFromCellCount#2");
  195. Assert.AreEqual ("True", dictionary[0].ToString (), "ExtractValuesFromCellValueTrue");
  196. }
  197. [Test]
  198. public void CheckBoxField_ValidateSupportsCallback ()
  199. {
  200. PokerCheckBoxField field = new PokerCheckBoxField ();
  201. field.ValidateSupportsCallback ();
  202. }
  203. [Test]
  204. public void CheckBoxField_CopyProperties()
  205. {
  206. PokerCheckBoxField field = new PokerCheckBoxField ();
  207. CheckBoxField copy = new CheckBoxField();
  208. field.DataField = "test";
  209. field.Text = "test";
  210. field.DoCopyProperties (copy);
  211. Assert.AreEqual ("test", copy.Text, "Text");
  212. Assert.AreEqual ("test", copy.DataField, "DataField");
  213. }
  214. [Test]
  215. public void CheckBoxField_CreateField ()
  216. {
  217. PokerCheckBoxField field = new PokerCheckBoxField ();
  218. CheckBoxField blank = (CheckBoxField)field.DoCreateField ();
  219. Assert.IsNotNull (blank, "CreateField");
  220. }
  221. [Test]
  222. public void CheckBoxField_GetDesignTimeValue ()
  223. {
  224. PokerCheckBoxField field = new PokerCheckBoxField ();
  225. bool result = (bool)field.DoGetDesignTimeValue ();
  226. Assert.AreEqual (true, result, "GetDesignTimeValue");
  227. }
  228. [Test]
  229. public void CheckBoxField_InitializeDataCell ()
  230. {
  231. PokerCheckBoxField field = new PokerCheckBoxField ();
  232. field.HeaderText = "headertest";
  233. DataControlFieldCell cell = new DataControlFieldCell (null);
  234. DataControlRowState state = DataControlRowState.Edit;
  235. Assert.AreEqual (0, cell.Controls.Count, "InitializeDataCellControlsBeforeInit");
  236. field.DoInitializeDataCell (cell, state);
  237. Assert.AreEqual (1, cell.Controls.Count, "InitializeDataCellControlsAfterInit");
  238. Assert.AreEqual ("headertest", ((CheckBox)cell.Controls[0]).ToolTip, "InitializeDataCellControlsData");
  239. cell.Controls.Clear ();
  240. field.DataField = "fake";
  241. field.Text = "celltext";
  242. state = DataControlRowState.Normal;
  243. field.DoInitializeDataCell (cell, state);
  244. Assert.AreEqual (1, cell.Controls.Count, "InitializeDataCellControlsAfterInit");
  245. Assert.AreEqual ("celltext", ((CheckBox) cell.Controls[0]).Text, "InitializeDataCellControlsData");
  246. }
  247. [Test]
  248. public void CheckBoxField_OnDataBindField ()
  249. {
  250. Page page = new Page ();
  251. GridView grid = new GridView ();
  252. page.Controls.Add (grid);
  253. grid.DataSource = this.CreateDataSource ();
  254. grid.AutoGenerateColumns = false;
  255. PokerCheckBoxField field = new PokerCheckBoxField ();
  256. field.HeaderText = "field_header";
  257. field.FooterText = "field_footer";
  258. field.DataField = FIELDNAME;
  259. grid.Columns.Add (field);
  260. grid.DataBind ();
  261. Assert.AreEqual (2, databound, "DataBindField");
  262. Assert.AreEqual (4, ((Control) grid.Controls[0]).Controls.Count, "DataBindFieldRowCountr");
  263. }
  264. [Test]
  265. [ExpectedException (typeof (HttpException))]
  266. public void CheckBoxField_OnDataBindFieldException ()
  267. {
  268. Page page = new Page ();
  269. GridView grid = new GridView ();
  270. page.Controls.Add (grid);
  271. grid.DataSource = this.CreateDataSource ();
  272. grid.AutoGenerateColumns = false;
  273. PokerCheckBoxField field = new PokerCheckBoxField ();
  274. field.HeaderText = "field_header";
  275. field.FooterText = "field_footer";
  276. field.DataField = WRONGFIELD;
  277. grid.Columns.Add (field);
  278. grid.DataBind ();
  279. }
  280. [Test]
  281. [ExpectedException(typeof(NotSupportedException))]
  282. public void CheckBoxField_GetApplyFormatInEditModeExeption ()
  283. {
  284. PokerCheckBoxField field = new PokerCheckBoxField ();
  285. bool stab = field.ApplyFormatInEditMode;
  286. }
  287. [Test]
  288. [ExpectedException (typeof (NotSupportedException))]
  289. public void CheckBoxField_SetApplyFormatInEditModeExeption ()
  290. {
  291. PokerCheckBoxField field = new PokerCheckBoxField ();
  292. field.ApplyFormatInEditMode = true;
  293. }
  294. [Test]
  295. [ExpectedException (typeof (NotSupportedException))]
  296. public void CheckBoxField_GetConvertEmptyStringToNull ()
  297. {
  298. PokerCheckBoxField field = new PokerCheckBoxField ();
  299. bool stab = field.ConvertEmptyStringToNull;
  300. }
  301. [Test]
  302. [ExpectedException (typeof (NotSupportedException))]
  303. public void CheckBoxField_SetConvertEmptyStringToNull ()
  304. {
  305. PokerCheckBoxField field = new PokerCheckBoxField ();
  306. field.ConvertEmptyStringToNull = true;
  307. }
  308. [Test]
  309. [ExpectedException (typeof (NotSupportedException))]
  310. public void CheckBoxField_SetDataFormatString ()
  311. {
  312. PokerCheckBoxField field = new PokerCheckBoxField ();
  313. field.DataFormatString = "";
  314. }
  315. [Test]
  316. [ExpectedException (typeof (NotSupportedException))]
  317. public void CheckBoxField_GetDataFormatString ()
  318. {
  319. PokerCheckBoxField field = new PokerCheckBoxField ();
  320. string res = field.DataFormatString;
  321. }
  322. [Test]
  323. [ExpectedException (typeof (NotSupportedException))]
  324. public void CheckBoxField_SetHtmlEncode ()
  325. {
  326. PokerCheckBoxField field = new PokerCheckBoxField ();
  327. field.HtmlEncode = true;
  328. }
  329. [Test]
  330. [ExpectedException (typeof (NotSupportedException))]
  331. public void CheckBoxField_GetHtmlEncode ()
  332. {
  333. PokerCheckBoxField field = new PokerCheckBoxField ();
  334. bool res = field.HtmlEncode;
  335. }
  336. [Test]
  337. [ExpectedException (typeof (NotSupportedException))]
  338. public void CheckBoxField_SetNullDisplayText ()
  339. {
  340. PokerCheckBoxField field = new PokerCheckBoxField ();
  341. field.NullDisplayText = "";
  342. }
  343. [Test]
  344. [ExpectedException (typeof (NotSupportedException))]
  345. public void CheckBoxField_GetNullDisplayText ()
  346. {
  347. PokerCheckBoxField field = new PokerCheckBoxField ();
  348. string res = field.NullDisplayText;
  349. }
  350. public DataTable CreateDataSource ()
  351. {
  352. DataTable aTable = new DataTable ("A");
  353. DataColumn dtCol;
  354. DataRow dtRow;
  355. // Create ID column and add to the DataTable.
  356. dtCol = new DataColumn ();
  357. dtCol.DataType = Type.GetType ("System.Boolean");
  358. dtCol.ColumnName = FIELDNAME;
  359. dtCol.Caption = FIELDNAME;
  360. dtCol.ReadOnly = true;
  361. // Add the column to the DataColumnCollection.
  362. aTable.Columns.Add (dtCol);
  363. dtCol = new DataColumn ();
  364. dtCol.DataType = Type.GetType ("System.String");
  365. dtCol.ColumnName = WRONGFIELD;
  366. dtCol.Caption = WRONGFIELD;
  367. dtCol.ReadOnly = true;
  368. // Add the column to the DataColumnCollection.
  369. aTable.Columns.Add (dtCol);
  370. // Create 2 rows to the table
  371. dtRow = aTable.NewRow ();
  372. dtRow[FIELDNAME] = true;
  373. dtRow[WRONGFIELD] = "1";
  374. aTable.Rows.Add (dtRow);
  375. dtRow = aTable.NewRow ();
  376. dtRow[FIELDNAME] = false;
  377. dtRow[WRONGFIELD] = "1";
  378. aTable.Rows.Add (dtRow);
  379. return aTable;
  380. }
  381. }
  382. }