2
0

BoundFieldTest.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  1. //
  2. // Tests for System.Web.UI.WebControls.BoundFieldTest.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 Image = System.Web.UI.WebControls.Image;
  39. using NUnit.Framework;
  40. using System.Globalization;
  41. using MonoTests.SystemWeb.Framework;
  42. using MonoTests.stand_alone.WebHarness;
  43. namespace MonoTests.System.Web.UI.WebControls
  44. {
  45. class EncodingTest
  46. {
  47. public override string ToString ()
  48. {
  49. return "<EncodingTest>&";
  50. }
  51. }
  52. class PokerBoundField : BoundField
  53. {
  54. public Button bindbutoon;
  55. public PokerBoundField () {
  56. TrackViewState ();
  57. bindbutoon = new Button ();
  58. bindbutoon.DataBinding += new EventHandler (OnDataBindField);
  59. }
  60. public StateBag StateBag {
  61. get { return base.ViewState; }
  62. }
  63. public bool DoSupportsHtmlEncode {
  64. get {
  65. return base.SupportsHtmlEncode;
  66. }
  67. }
  68. public void DoCopyProperties (DataControlField newField) {
  69. base.CopyProperties (newField);
  70. }
  71. public DataControlField DoCreateField () {
  72. return base.CreateField ();
  73. }
  74. public string DoFormatDataValue (object dataValue, bool encode) {
  75. return this.FormatDataValue (dataValue, encode);
  76. }
  77. public object DoGetDesignTimeValue () {
  78. return base.GetDesignTimeValue ();
  79. }
  80. public object DoGetValue (Control controlContainer) {
  81. return base.GetValue (controlContainer);
  82. }
  83. public void DoInitializeDataCell (DataControlFieldCell cell, DataControlRowState rowState) {
  84. base.InitializeDataCell (cell, rowState);
  85. }
  86. public void DoOnDataBindField (object sender, EventArgs e) {
  87. base.OnDataBindField (sender, e);
  88. }
  89. public Control GetControl {
  90. get { return base.Control; }
  91. }
  92. public object DoSaveViewState ()
  93. {
  94. return SaveViewState ();
  95. }
  96. }
  97. [Serializable]
  98. [TestFixture]
  99. public class BoundFieldTest
  100. {
  101. [TestFixtureSetUp]
  102. public void SetUp ()
  103. {
  104. WebTest.CopyResource (GetType (), "BoundField_Bug646505.aspx", "BoundField_Bug646505.aspx");
  105. WebTest.CopyResource (GetType (), "BoundField_Bug646505.aspx.cs", "BoundField_Bug646505.aspx.cs");
  106. }
  107. [Test (Description="Bug 646505")]
  108. public void BoundField_Bug646505 ()
  109. {
  110. string originalHtml = "<div>\n\t<table cellspacing=\"0\" rules=\"all\" border=\"1\" id=\"gridView\" style=\"border-collapse:collapse;\">\n\t\t<tr>\n\t\t\t<th scope=\"col\">&nbsp;</th><th scope=\"col\">&nbsp;</th>\n\t\t</tr><tr>\n\t\t\t<td><a href=\"javascript:__doPostBack(&#39;gridView$ctl02$ctl00&#39;,&#39;&#39;)\">Update</a>&nbsp;<a href=\"javascript:__doPostBack(&#39;gridView&#39;,&#39;Cancel$0&#39;)\">Cancel</a></td><td><input name=\"gridView$ctl02$ctl02\" type=\"text\" value=\"False\" /></td>\n\t\t</tr><tr>\n\t\t\t<td><a href=\"javascript:__doPostBack(&#39;gridView&#39;,&#39;Edit$1&#39;)\">Edit</a></td><td>False</td>\n\t\t</tr>\n\t</table>\n</div>\n";
  111. WebTest t = new WebTest ("BoundField_Bug646505.aspx");
  112. t.Run ();
  113. FormRequest fr = new FormRequest (t.Response, "form1");
  114. fr.Controls.Add ("__EVENTTARGET");
  115. fr.Controls.Add ("__EVENTARGUMENT");
  116. fr.Controls ["__EVENTTARGET"].Value = "gridView";
  117. fr.Controls ["__EVENTARGUMENT"].Value = "Edit$0";
  118. t.Request = fr;
  119. string pageHtml = t.Run ();
  120. string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHtml);
  121. HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "#A1");
  122. }
  123. [Test]
  124. public void BoundField_DefaultProperty () {
  125. PokerBoundField bf = new PokerBoundField ();
  126. Assert.AreEqual ("!", PokerBoundField.ThisExpression, "StaticThisExpression");
  127. Assert.AreEqual ("", bf.DataField, "DataField");
  128. Assert.AreEqual ("", bf.DataFormatString, "DataFormatString");
  129. Assert.AreEqual ("", bf.HeaderText, "HeaderText");
  130. Assert.AreEqual (true, bf.HtmlEncode, "HtmlEncode");
  131. Assert.AreEqual ("", bf.NullDisplayText, "NullDisplayText");
  132. Assert.AreEqual (false, bf.ReadOnly, "ReadOnly");
  133. //Protected
  134. Assert.AreEqual (true, bf.DoSupportsHtmlEncode, "SupportsHtmlEncode");
  135. }
  136. [Test]
  137. public void BoundField_DefaultPropertyNotWorking () {
  138. PokerBoundField bf = new PokerBoundField ();
  139. Assert.AreEqual (false, bf.ApplyFormatInEditMode, "ApplyFormatInEditMode");
  140. Assert.AreEqual (true, bf.ConvertEmptyStringToNull, "ConvertEmptyStringToNull");
  141. }
  142. [Test]
  143. public void BoundField_AssignProperty () {
  144. PokerBoundField bf = new PokerBoundField ();
  145. bf.ConvertEmptyStringToNull = false;
  146. Assert.AreEqual (false, bf.ConvertEmptyStringToNull, "ConvertEmptyStringToNull");
  147. bf.DataField = "test";
  148. Assert.AreEqual ("test", bf.DataField, "DataField");
  149. bf.DataFormatString = "test";
  150. Assert.AreEqual ("test", bf.DataFormatString, "DataFormatString");
  151. bf.HeaderText = "test";
  152. Assert.AreEqual ("test", bf.HeaderText, "HeaderText");
  153. bf.HtmlEncode = false;
  154. Assert.AreEqual (false, bf.HtmlEncode, "HtmlEncode");
  155. bf.NullDisplayText = "test";
  156. Assert.AreEqual ("test", bf.NullDisplayText, "NullDisplayText");
  157. bf.ReadOnly = true;
  158. Assert.AreEqual (true, bf.ReadOnly, "ReadOnly");
  159. }
  160. [Test]
  161. public void BoundField_AssignPropertyNotWorking () {
  162. PokerBoundField bf = new PokerBoundField ();
  163. bf.ApplyFormatInEditMode = true;
  164. Assert.AreEqual (true, bf.ApplyFormatInEditMode, "ApplyFormatInEditMode");
  165. }
  166. [Test]
  167. public void BoundField_ExtractValuesFromCell () {
  168. PokerBoundField bf = new PokerBoundField ();
  169. OrderedDictionary dictionary = new OrderedDictionary ();
  170. DataControlFieldCell cell = new DataControlFieldCell (null);
  171. cell.Text = "test";
  172. bf.ExtractValuesFromCell (dictionary, cell, DataControlRowState.Normal, true);
  173. Assert.AreEqual (1, dictionary.Count, "ExtractValuesFromCellCount");
  174. Assert.AreEqual ("test", dictionary [0].ToString (), "ExtractValuesFromCellValue");
  175. }
  176. [Test]
  177. public void BoundField_Initialize () {
  178. // This method initilize to private fields in a base class DataControlField
  179. // Always return false
  180. PokerBoundField bf = new PokerBoundField ();
  181. Control control = new Control ();
  182. control.ID = "test";
  183. bool res = bf.Initialize (true, control);
  184. // Assert.AreEqual (false, res, "InitializeResult");
  185. Assert.AreEqual ("test", bf.GetControl.ID, "InitializeControl");
  186. }
  187. [Test]
  188. public void BoundField_InitializeCell () {
  189. PokerBoundField bf = new PokerBoundField ();
  190. // Header text
  191. DataControlFieldCell cell = new DataControlFieldCell (null);
  192. bf.HeaderText = "headertext";
  193. bf.InitializeCell (cell, DataControlCellType.Header, DataControlRowState.Edit, 1);
  194. Assert.AreEqual ("headertext", cell.Text, "InitializeCellHeaderText");
  195. // Empty header text
  196. bf.HeaderText = "";
  197. bf.InitializeCell (cell, DataControlCellType.Header, DataControlRowState.Edit, 1);
  198. Assert.AreEqual ("&nbsp;", cell.Text, "InitializeCellEmpty");
  199. bf.HeaderText = "headertext";
  200. // Header image url not empty
  201. bf.HeaderImageUrl = "headerurl";
  202. bf.InitializeCell (cell, DataControlCellType.Header, DataControlRowState.Edit, 1);
  203. if (cell.Controls [0] is Image) {
  204. Image image = (Image) cell.Controls [0];
  205. Assert.AreEqual ("headerurl", image.ImageUrl, "InitializeCellHeaderImageUrl");
  206. }
  207. else {
  208. Assert.Fail ("Header Image dos not created");
  209. }
  210. // Footer empty
  211. bf.FooterText = "footertext";
  212. bf.InitializeCell (cell, DataControlCellType.Footer, DataControlRowState.Edit, 1);
  213. Assert.AreEqual ("footertext", cell.Text, "InitializeCellFooterText");
  214. bf.FooterText = "";
  215. bf.InitializeCell (cell, DataControlCellType.Footer, DataControlRowState.Edit, 1);
  216. Assert.AreEqual ("&nbsp;", cell.Text, "InitializeCellFooterEmpty");
  217. }
  218. [Test]
  219. public void BoundField_ValidateSupportsCallback () {
  220. //This method has been implemented as an empty method
  221. }
  222. [Test]
  223. public void BoundField_SortExpression () {
  224. // Sorting enable = true , link button must be created
  225. PokerBoundField bf = new PokerBoundField ();
  226. // Header text
  227. DataControlFieldCell cell = new DataControlFieldCell (null);
  228. bf.HeaderImageUrl = "";
  229. bf.SortExpression = "a";
  230. bf.HeaderText = "sortbutton";
  231. bf.Initialize (true, new Control ()); // _base._sortingenable set to true
  232. bf.InitializeCell (cell, DataControlCellType.Header, DataControlRowState.Edit, 1);
  233. if (cell.Controls [0] is Button) { // mono
  234. Button lb = (Button) cell.Controls [0];
  235. Assert.AreEqual ("Sort", lb.CommandName, "InitializeCellHeaderSortButtonCommand");
  236. Assert.AreEqual ("a", lb.CommandArgument, "InitializeCellHeaderSortButtonArgument");
  237. Assert.AreEqual ("sortbutton", lb.Text, "InitializeCellHeaderSortButtonText");
  238. }
  239. else if (cell.Controls [0] is LinkButton) { // .net
  240. LinkButton lb = (LinkButton) cell.Controls [0];
  241. Assert.AreEqual ("Sort", lb.CommandName, "InitializeCellHeaderSortButtonCommand");
  242. Assert.AreEqual ("a", lb.CommandArgument, "InitializeCellHeaderSortButtonArgument");
  243. Assert.AreEqual ("sortbutton", lb.Text, "InitializeCellHeaderSortButtonText");
  244. }
  245. else {
  246. Assert.Fail ("Sort button does not created");
  247. }
  248. }
  249. [Test]
  250. public void BoundField_CopyProperties () {
  251. PokerBoundField bf = new PokerBoundField ();
  252. BoundField copy = new BoundField ();
  253. // Look not working property
  254. // bf.ApplyFormatInEditMode = true;
  255. bf.ConvertEmptyStringToNull = true;
  256. bf.DataField = "test";
  257. bf.DataFormatString = "test";
  258. bf.HtmlEncode = true;
  259. bf.NullDisplayText = "test";
  260. bf.ReadOnly = true;
  261. bf.DoCopyProperties (copy);
  262. // Look not working property
  263. // Assert.AreEqual (true, copy.ApplyFormatInEditMode, "ApplyFormatInEditMode");
  264. Assert.AreEqual (true, copy.ConvertEmptyStringToNull, "ConvertEmptyStringToNull");
  265. Assert.AreEqual ("test", copy.DataField, "DataField");
  266. Assert.AreEqual ("test", copy.DataFormatString, "DataFormatString");
  267. Assert.AreEqual (true, copy.HtmlEncode, "HtmlEncode");
  268. Assert.AreEqual ("test", copy.NullDisplayText, "NullDisplayText");
  269. Assert.AreEqual (true, copy.ReadOnly, "ReadOnly");
  270. }
  271. [Test]
  272. public void BoundField_CreateField () {
  273. PokerBoundField bf = new PokerBoundField ();
  274. BoundField newfield = (BoundField) bf.DoCreateField ();
  275. Assert.IsNotNull (newfield, "CreateField");
  276. }
  277. [Test]
  278. public void BoundField_FormatDataValue () {
  279. string result;
  280. PokerBoundField bf = new PokerBoundField ();
  281. bf.NullDisplayText = "NullDisplayText";
  282. result = bf.DoFormatDataValue (null, false);
  283. Assert.AreEqual ("NullDisplayText", result, "FormatDataValueNullDataValue");
  284. result = bf.DoFormatDataValue ("test", true);
  285. Assert.AreEqual ("test", result, "FormatDataValueTextDataValue");
  286. result = bf.DoFormatDataValue ("", true);
  287. Assert.AreEqual ("NullDisplayText", result, "FormatEmptyDataValue");
  288. bf.DataFormatString = "-{0,8:G}-";
  289. result = bf.DoFormatDataValue (10, false);
  290. Assert.AreEqual ("- 10-", result, "FormatDataValueWithFormat");
  291. bf.DataFormatString = "-{0:X}-";
  292. result = bf.DoFormatDataValue (10, true);
  293. Assert.AreEqual ("-A-", result, "FormatDataValueWithFormatAndHtmlEncode");
  294. bf.DataFormatString = "-{0:X}-";
  295. result = bf.DoFormatDataValue (10, false);
  296. Assert.AreEqual ("-A-", result, "FormatDataValueWithFormatAndNoHtmlEncode");
  297. bf.HtmlEncodeFormatString = false;
  298. bf.DataFormatString = "-{0:X}-";
  299. result = bf.DoFormatDataValue (10, true);
  300. Assert.AreEqual ("-10-", result, "NoHtmlEncodeFormatString_HtmlEncode");
  301. bf.DataFormatString = "-{0:X}-";
  302. result = bf.DoFormatDataValue (10, false);
  303. Assert.AreEqual ("-A-", result, "NoHtmlEncodeFormatString_NoHtmlEncode");
  304. }
  305. [Test]
  306. public void HtmlEncodeFormatString ()
  307. {
  308. string formatString = "<script>alert ('{0}');</script>";
  309. var bf = new PokerBoundField ();
  310. Assert.IsTrue (bf.HtmlEncodeFormatString, "#A1-2");
  311. Assert.IsTrue (bf.HtmlEncode, "#A1-2");
  312. Assert.IsTrue (bf.DoSupportsHtmlEncode, "#A1-3");
  313. bf.DataFormatString = formatString;
  314. Assert.AreEqual ("&lt;script&gt;alert (&#39;&lt;test&gt;&#39;);&lt;/script&gt;", bf.DoFormatDataValue ("<test>", true), "#A2");
  315. Assert.AreEqual (String.Format (formatString, "<test>"), bf.DoFormatDataValue ("<test>", false), "#A3");
  316. bf.HtmlEncodeFormatString = false;
  317. Assert.AreEqual ("<script>alert ('&lt;test&gt;');</script>", bf.DoFormatDataValue ("<test>", true), "#A4");
  318. var ec = new EncodingTest ();
  319. bf.HtmlEncodeFormatString = true;
  320. Assert.AreEqual ("&lt;script&gt;alert (&#39;&lt;EncodingTest&gt;&amp;&#39;);&lt;/script&gt;", bf.DoFormatDataValue (ec, true), "#A4");
  321. }
  322. [Test]
  323. public void BoundField_GetDesignTimeValue () {
  324. string result;
  325. PokerBoundField bf = new PokerBoundField ();
  326. result = (string) bf.DoGetDesignTimeValue ();
  327. Assert.AreEqual ("Databound", result, "GetDesignTimeValue");
  328. }
  329. [Test]
  330. [ExpectedException(typeof(HttpException), ExpectedMessage="A data item was not found in the container. The container must either implement IDataItemContainer, or have a property named DataItem.")]
  331. public void BoundField_GetValueNull () {
  332. PokerBoundField bf = new PokerBoundField ();
  333. SimpleSpreadsheetRow ds = new SimpleSpreadsheetRow (0, null);
  334. bf.DataField = PokerBoundField.ThisExpression;
  335. string result = (string) bf.DoGetValue (ds);
  336. }
  337. [Test]
  338. public void BoundField_GetValue () {
  339. PokerBoundField bf = new PokerBoundField ();
  340. SimpleSpreadsheetRow ds = new SimpleSpreadsheetRow (0, "test");
  341. bf.DataField = PokerBoundField.ThisExpression;
  342. string result = (string) bf.DoGetValue (ds);
  343. Assert.AreEqual ("test", result, "GetValueFromIDataItemContainer");
  344. }
  345. [Test]
  346. public void BoundField_GetValueDataItem () {
  347. PokerBoundField bf = new PokerBoundField ();
  348. ControlWithDataItem ds = new ControlWithDataItem ("test");
  349. bf.DataField = PokerBoundField.ThisExpression;
  350. string result = (string) bf.DoGetValue (ds);
  351. Assert.AreEqual ("test", result, "GetValueFromIDataItemContainer");
  352. }
  353. [Test]
  354. public void BoundField_InitializeDataCell () {
  355. PokerBoundField bf = new PokerBoundField ();
  356. bf.HeaderText = "headertest";
  357. DataControlFieldCell cell = new DataControlFieldCell (null);
  358. DataControlRowState state = DataControlRowState.Edit;
  359. Assert.AreEqual (0, cell.Controls.Count, "InitializeDataCellControlsBeforeInit");
  360. bf.DoInitializeDataCell (cell, state);
  361. Assert.AreEqual (1, cell.Controls.Count, "InitializeDataCellControlsAfterInit");
  362. }
  363. [Test]
  364. [ExpectedException (typeof (HttpException))]
  365. public void BoundField_OnDataBindFieldExeption () {
  366. PokerBoundField bf = new PokerBoundField ();
  367. bf.bindbutoon.DataBind ();
  368. }
  369. [Test]
  370. [ExpectedException (typeof (HttpException))]
  371. public void BoundField_GetValueExeption () {
  372. PokerBoundField bf = new PokerBoundField ();
  373. bf.DoGetValue (null);
  374. }
  375. [Test]
  376. [Category ("NunitWeb")]
  377. public void BoundField_NullValueRender ()
  378. {
  379. string html = new WebTest (PageInvoker.CreateOnLoad (new PageDelegate (BasicRenderTestInit))).Run ();
  380. string orightml = "<div>\r\n\t<table cellspacing=\"0\" rules=\"all\" border=\"1\" style=\"border-collapse:collapse;\">\r\n\t\t<tr>\r\n\t\t\t<th scope=\"col\">&nbsp;</th><th scope=\"col\">&nbsp;</th>\r\n\t\t</tr><tr>\r\n\t\t\t<td>Norway</td><td>Norway</td>\r\n\t\t</tr><tr>\r\n\t\t\t<td>Sweden</td><td>Sweden</td>\r\n\t\t</tr><tr>\r\n\t\t\t<td>EMPTY</td><td>&nbsp;</td>\r\n\t\t</tr><tr>\r\n\t\t\t<td>Italy</td><td>Italy</td>\r\n\t\t</tr>\r\n\t</table>\r\n</div>";
  381. html = HtmlDiff.GetControlFromPageHtml (html);
  382. HtmlDiff.AssertAreEqual (orightml, html, "NullValueRender");
  383. }
  384. public static void BasicRenderTestInit (Page p)
  385. {
  386. ArrayList myds = new ArrayList ();
  387. myds.Add (new myds_data ("Norway"));
  388. myds.Add (new myds_data ("Sweden"));
  389. myds.Add (new myds_data (""));
  390. myds.Add (new myds_data ("Italy"));
  391. BoundField bf = new BoundField ();
  392. bf.DataField = "Field1";
  393. bf.NullDisplayText = "EMPTY";
  394. BoundField bf2 = new BoundField ();
  395. bf2.DataField = "Field1";
  396. GridView GridView1 = new GridView();
  397. GridView1.AutoGenerateColumns = false;
  398. GridView1.Columns.Add (bf);
  399. GridView1.Columns.Add (bf2);
  400. GridView1.DataSource = myds;
  401. GridView1.DataBind ();
  402. LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG);
  403. LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG);
  404. p.Form.Controls.Add (lcb);
  405. p.Form.Controls.Add (GridView1);
  406. p.Form.Controls.Add (lce);
  407. }
  408. class myds_data
  409. {
  410. string _s = "";
  411. public myds_data (string s)
  412. {
  413. _s = s;
  414. }
  415. public string Field1
  416. {
  417. get { return _s; }
  418. }
  419. }
  420. class ControlWithDataItem : Control
  421. {
  422. readonly object _data;
  423. public ControlWithDataItem (object data) {
  424. _data = data;
  425. }
  426. public object DataItem {
  427. get {
  428. return _data;
  429. }
  430. }
  431. }
  432. public class SimpleSpreadsheetRow : TableRow, IDataItemContainer
  433. {
  434. private object data;
  435. private int _itemIndex;
  436. public SimpleSpreadsheetRow (int itemIndex, object o) {
  437. data = o;
  438. _itemIndex = itemIndex;
  439. }
  440. public virtual object Data {
  441. get {
  442. return data;
  443. }
  444. }
  445. object IDataItemContainer.DataItem {
  446. get {
  447. return Data;
  448. }
  449. }
  450. int IDataItemContainer.DataItemIndex {
  451. get {
  452. return _itemIndex;
  453. }
  454. }
  455. int IDataItemContainer.DisplayIndex {
  456. get {
  457. return _itemIndex;
  458. }
  459. }
  460. }
  461. }
  462. }