DetailsView.cs 54 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803
  1. //
  2. // System.Web.UI.WebControls.DetailsView.cs
  3. //
  4. // Authors:
  5. // Lluis Sanchez Gual ([email protected])
  6. //
  7. // (C) 2005 Novell, Inc (http://www.novell.com)
  8. //
  9. // Permission is hereby granted, free of charge, to any person obtaining
  10. // a copy of this software and associated documentation files (the
  11. // "Software"), to deal in the Software without restriction, including
  12. // without limitation the rights to use, copy, modify, merge, publish,
  13. // distribute, sublicense, and/or sell copies of the Software, and to
  14. // permit persons to whom the Software is furnished to do so, subject to
  15. // the following conditions:
  16. //
  17. // The above copyright notice and this permission notice shall be
  18. // included in all copies or substantial portions of the Software.
  19. //
  20. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  21. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  22. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  23. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  24. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  25. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  26. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  27. //
  28. #if NET_2_0
  29. using System;
  30. using System.Collections;
  31. using System.Collections.Specialized;
  32. using System.ComponentModel;
  33. using System.Web.UI;
  34. using System.Security.Permissions;
  35. using System.Text;
  36. using System.IO;
  37. using System.Reflection;
  38. namespace System.Web.UI.WebControls
  39. {
  40. [SupportsEventValidation]
  41. [ToolboxDataAttribute ("<{0}:DetailsView runat=\"server\" Width=\"125px\" Height=\"50px\"></{0}:DetailsView>")]
  42. [DesignerAttribute ("System.Web.UI.Design.WebControls.DetailsViewDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
  43. [ControlValuePropertyAttribute ("SelectedValue")]
  44. [DefaultEventAttribute ("PageIndexChanging")]
  45. [AspNetHostingPermissionAttribute (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
  46. [AspNetHostingPermissionAttribute (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
  47. public class DetailsView: CompositeDataBoundControl, ICallbackEventHandler, ICallbackContainer, IDataItemContainer, INamingContainer, IPostBackEventHandler, IPostBackContainer
  48. {
  49. object dataItem;
  50. Table table;
  51. DetailsViewRowCollection rows;
  52. DetailsViewRow headerRow;
  53. DetailsViewRow footerRow;
  54. DetailsViewRow bottomPagerRow;
  55. DetailsViewRow topPagerRow;
  56. IOrderedDictionary currentEditRowKeys;
  57. IOrderedDictionary currentEditNewValues;
  58. IOrderedDictionary currentEditOldValues;
  59. ITemplate pagerTemplate;
  60. ITemplate emptyDataTemplate;
  61. ITemplate headerTemplate;
  62. ITemplate footerTemplate;
  63. PropertyDescriptor[] cachedKeyProperties;
  64. readonly string[] emptyKeys = new string[0];
  65. CommandField commandField;
  66. DetailsViewRow commandRow;
  67. // View state
  68. DataControlFieldCollection columns;
  69. PagerSettings pagerSettings;
  70. TableItemStyle alternatingRowStyle;
  71. TableItemStyle editRowStyle;
  72. TableItemStyle insertRowStyle;
  73. TableItemStyle emptyDataRowStyle;
  74. TableItemStyle footerStyle;
  75. TableItemStyle headerStyle;
  76. TableItemStyle pagerStyle;
  77. TableItemStyle rowStyle;
  78. TableItemStyle commandRowStyle;
  79. TableItemStyle fieldHeaderStyle;
  80. DataKey key;
  81. DataKey oldEditValues;
  82. AutoGeneratedFieldProperties[] autoFieldProperties;
  83. private static readonly object PageIndexChangedEvent = new object();
  84. private static readonly object PageIndexChangingEvent = new object();
  85. private static readonly object ItemCommandEvent = new object();
  86. private static readonly object ItemCreatedEvent = new object();
  87. private static readonly object ItemDeletedEvent = new object();
  88. private static readonly object ItemDeletingEvent = new object();
  89. private static readonly object ItemInsertedEvent = new object();
  90. private static readonly object ItemInsertingEvent = new object();
  91. private static readonly object ModeChangingEvent = new object();
  92. private static readonly object ModeChangedEvent = new object();
  93. private static readonly object ItemUpdatedEvent = new object();
  94. private static readonly object ItemUpdatingEvent = new object();
  95. // Control state
  96. int pageIndex;
  97. DetailsViewMode currentMode = DetailsViewMode.ReadOnly;
  98. int pageCount = -1;
  99. public DetailsView ()
  100. {
  101. }
  102. public event EventHandler PageIndexChanged {
  103. add { Events.AddHandler (PageIndexChangedEvent, value); }
  104. remove { Events.RemoveHandler (PageIndexChangedEvent, value); }
  105. }
  106. public event DetailsViewPageEventHandler PageIndexChanging {
  107. add { Events.AddHandler (PageIndexChangingEvent, value); }
  108. remove { Events.RemoveHandler (PageIndexChangingEvent, value); }
  109. }
  110. public event DetailsViewCommandEventHandler ItemCommand {
  111. add { Events.AddHandler (ItemCommandEvent, value); }
  112. remove { Events.RemoveHandler (ItemCommandEvent, value); }
  113. }
  114. public event EventHandler ItemCreated {
  115. add { Events.AddHandler (ItemCreatedEvent, value); }
  116. remove { Events.RemoveHandler (ItemCreatedEvent, value); }
  117. }
  118. public event DetailsViewDeletedEventHandler ItemDeleted {
  119. add { Events.AddHandler (ItemDeletedEvent, value); }
  120. remove { Events.RemoveHandler (ItemDeletedEvent, value); }
  121. }
  122. public event DetailsViewDeleteEventHandler ItemDeleting {
  123. add { Events.AddHandler (ItemDeletingEvent, value); }
  124. remove { Events.RemoveHandler (ItemDeletingEvent, value); }
  125. }
  126. public event DetailsViewInsertedEventHandler ItemInserted {
  127. add { Events.AddHandler (ItemInsertedEvent, value); }
  128. remove { Events.RemoveHandler (ItemInsertedEvent, value); }
  129. }
  130. public event DetailsViewInsertEventHandler ItemInserting {
  131. add { Events.AddHandler (ItemInsertingEvent, value); }
  132. remove { Events.RemoveHandler (ItemInsertingEvent, value); }
  133. }
  134. public event DetailsViewModeEventHandler ModeChanging {
  135. add { Events.AddHandler (ModeChangingEvent, value); }
  136. remove { Events.RemoveHandler (ModeChangingEvent, value); }
  137. }
  138. public event EventHandler ModeChanged {
  139. add { Events.AddHandler (ModeChangedEvent, value); }
  140. remove { Events.RemoveHandler (ModeChangedEvent, value); }
  141. }
  142. public event DetailsViewUpdatedEventHandler ItemUpdated {
  143. add { Events.AddHandler (ItemUpdatedEvent, value); }
  144. remove { Events.RemoveHandler (ItemUpdatedEvent, value); }
  145. }
  146. public event DetailsViewUpdateEventHandler ItemUpdating {
  147. add { Events.AddHandler (ItemUpdatingEvent, value); }
  148. remove { Events.RemoveHandler (ItemUpdatingEvent, value); }
  149. }
  150. protected virtual void OnPageIndexChanged (EventArgs e)
  151. {
  152. if (Events != null) {
  153. EventHandler eh = (EventHandler) Events [PageIndexChangedEvent];
  154. if (eh != null) eh (this, e);
  155. }
  156. }
  157. protected virtual void OnPageIndexChanging (DetailsViewPageEventArgs e)
  158. {
  159. if (Events != null) {
  160. DetailsViewPageEventHandler eh = (DetailsViewPageEventHandler) Events [PageIndexChangingEvent];
  161. if (eh != null) eh (this, e);
  162. }
  163. }
  164. protected virtual void OnItemCommand (DetailsViewCommandEventArgs e)
  165. {
  166. if (Events != null) {
  167. DetailsViewCommandEventHandler eh = (DetailsViewCommandEventHandler) Events [ItemCommandEvent];
  168. if (eh != null) eh (this, e);
  169. }
  170. }
  171. protected virtual void OnItemCreated (EventArgs e)
  172. {
  173. if (Events != null) {
  174. EventHandler eh = (EventHandler) Events [ItemCreatedEvent];
  175. if (eh != null) eh (this, e);
  176. }
  177. }
  178. protected virtual void OnItemDeleted (DetailsViewDeletedEventArgs e)
  179. {
  180. if (Events != null) {
  181. DetailsViewDeletedEventHandler eh = (DetailsViewDeletedEventHandler) Events [ItemDeletedEvent];
  182. if (eh != null) eh (this, e);
  183. }
  184. }
  185. protected virtual void OnItemInserted (DetailsViewInsertedEventArgs e)
  186. {
  187. if (Events != null) {
  188. DetailsViewInsertedEventHandler eh = (DetailsViewInsertedEventHandler) Events [ItemInsertedEvent];
  189. if (eh != null) eh (this, e);
  190. }
  191. }
  192. protected virtual void OnItemInserting (DetailsViewInsertEventArgs e)
  193. {
  194. if (Events != null) {
  195. DetailsViewInsertEventHandler eh = (DetailsViewInsertEventHandler) Events [ItemInsertingEvent];
  196. if (eh != null) eh (this, e);
  197. }
  198. }
  199. protected virtual void OnItemDeleting (DetailsViewDeleteEventArgs e)
  200. {
  201. if (Events != null) {
  202. DetailsViewDeleteEventHandler eh = (DetailsViewDeleteEventHandler) Events [ItemDeletingEvent];
  203. if (eh != null) eh (this, e);
  204. }
  205. }
  206. protected virtual void OnModeChanged (EventArgs e)
  207. {
  208. if (Events != null) {
  209. EventHandler eh = (EventHandler) Events [ModeChangedEvent];
  210. if (eh != null) eh (this, e);
  211. }
  212. }
  213. protected virtual void OnModeChanging (DetailsViewModeEventArgs e)
  214. {
  215. if (Events != null) {
  216. DetailsViewModeEventHandler eh = (DetailsViewModeEventHandler) Events [ModeChangingEvent];
  217. if (eh != null) eh (this, e);
  218. }
  219. }
  220. protected virtual void OnItemUpdated (DetailsViewUpdatedEventArgs e)
  221. {
  222. if (Events != null) {
  223. DetailsViewUpdatedEventHandler eh = (DetailsViewUpdatedEventHandler) Events [ItemUpdatedEvent];
  224. if (eh != null) eh (this, e);
  225. }
  226. }
  227. protected virtual void OnItemUpdating (DetailsViewUpdateEventArgs e)
  228. {
  229. if (Events != null) {
  230. DetailsViewUpdateEventHandler eh = (DetailsViewUpdateEventHandler) Events [ItemUpdatingEvent];
  231. if (eh != null) eh (this, e);
  232. }
  233. }
  234. [WebCategoryAttribute ("Paging")]
  235. [DefaultValueAttribute (false)]
  236. public virtual bool AllowPaging {
  237. get {
  238. object ob = ViewState ["AllowPaging"];
  239. if (ob != null) return (bool) ob;
  240. return false;
  241. }
  242. set {
  243. ViewState ["AllowPaging"] = value;
  244. RequireBinding ();
  245. }
  246. }
  247. [DefaultValueAttribute (null)]
  248. [WebCategoryAttribute ("Styles")]
  249. [PersistenceMode (PersistenceMode.InnerProperty)]
  250. [NotifyParentProperty (true)]
  251. [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
  252. public TableItemStyle AlternatingRowStyle {
  253. get {
  254. if (alternatingRowStyle == null) {
  255. alternatingRowStyle = new TableItemStyle ();
  256. if (IsTrackingViewState)
  257. alternatingRowStyle.TrackViewState();
  258. }
  259. return alternatingRowStyle;
  260. }
  261. }
  262. [WebCategoryAttribute ("Behavior")]
  263. [DefaultValueAttribute (false)]
  264. public virtual bool AutoGenerateEditButton {
  265. get {
  266. object ob = ViewState ["AutoGenerateEditButton"];
  267. if (ob != null) return (bool) ob;
  268. return false;
  269. }
  270. set {
  271. ViewState ["AutoGenerateEditButton"] = value;
  272. RequireBinding ();
  273. }
  274. }
  275. [WebCategoryAttribute ("Behavior")]
  276. [DefaultValueAttribute (false)]
  277. public virtual bool AutoGenerateDeleteButton {
  278. get {
  279. object ob = ViewState ["AutoGenerateDeleteButton"];
  280. if (ob != null) return (bool) ob;
  281. return false;
  282. }
  283. set {
  284. ViewState ["AutoGenerateDeleteButton"] = value;
  285. RequireBinding ();
  286. }
  287. }
  288. [WebCategoryAttribute ("Behavior")]
  289. [DefaultValueAttribute (false)]
  290. public virtual bool AutoGenerateInsertButton {
  291. get {
  292. object ob = ViewState ["AutoGenerateInsertButton"];
  293. if (ob != null) return (bool) ob;
  294. return false;
  295. }
  296. set {
  297. ViewState ["AutoGenerateInsertButton"] = value;
  298. RequireBinding ();
  299. }
  300. }
  301. [WebCategoryAttribute ("Behavior")]
  302. [DefaultValueAttribute (true)]
  303. public virtual bool AutoGenerateRows {
  304. get {
  305. object ob = ViewState ["AutoGenerateRows"];
  306. if (ob != null) return (bool) ob;
  307. return true;
  308. }
  309. set {
  310. ViewState ["AutoGenerateRows"] = value;
  311. RequireBinding ();
  312. }
  313. }
  314. [UrlPropertyAttribute]
  315. [WebCategoryAttribute ("Appearance")]
  316. [DefaultValueAttribute ("")]
  317. [EditorAttribute ("System.Web.UI.Design.ImageUrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
  318. public virtual string BackImageUrl {
  319. get {
  320. object ob = ViewState ["BackImageUrl"];
  321. if (ob != null) return (string) ob;
  322. return string.Empty;
  323. }
  324. set {
  325. ViewState ["BackImageUrl"] = value;
  326. RequireBinding ();
  327. }
  328. }
  329. [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
  330. [BrowsableAttribute (false)]
  331. public virtual DetailsViewRow BottomPagerRow {
  332. get {
  333. EnsureDataBound ();
  334. return bottomPagerRow;
  335. }
  336. }
  337. [WebCategoryAttribute ("Accessibility")]
  338. [DefaultValueAttribute ("")]
  339. [LocalizableAttribute (true)]
  340. public virtual string Caption {
  341. get {
  342. object ob = ViewState ["Caption"];
  343. if (ob != null) return (string) ob;
  344. return string.Empty;
  345. }
  346. set {
  347. ViewState ["Caption"] = value;
  348. RequireBinding ();
  349. }
  350. }
  351. [WebCategoryAttribute ("Accessibility")]
  352. [DefaultValueAttribute (TableCaptionAlign.NotSet)]
  353. public virtual TableCaptionAlign CaptionAlign
  354. {
  355. get {
  356. object o = ViewState ["CaptionAlign"];
  357. if(o != null) return (TableCaptionAlign) o;
  358. return TableCaptionAlign.NotSet;
  359. }
  360. set {
  361. ViewState ["CaptionAlign"] = value;
  362. RequireBinding ();
  363. }
  364. }
  365. [WebCategoryAttribute ("Layout")]
  366. [DefaultValueAttribute (-1)]
  367. public virtual int CellPadding
  368. {
  369. get {
  370. object o = ViewState ["CellPadding"];
  371. if (o != null) return (int) o;
  372. return -1;
  373. }
  374. set {
  375. ViewState ["CellPadding"] = value;
  376. RequireBinding ();
  377. }
  378. }
  379. [WebCategoryAttribute ("Layout")]
  380. [DefaultValueAttribute (0)]
  381. public virtual int CellSpacing
  382. {
  383. get {
  384. object o = ViewState ["CellSpacing"];
  385. if (o != null) return (int) o;
  386. return 0;
  387. }
  388. set {
  389. ViewState ["CellSpacing"] = value;
  390. RequireBinding ();
  391. }
  392. }
  393. [DefaultValueAttribute (null)]
  394. [WebCategoryAttribute ("Styles")]
  395. [PersistenceMode (PersistenceMode.InnerProperty)]
  396. [NotifyParentProperty (true)]
  397. [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
  398. public TableItemStyle CommandRowStyle {
  399. get {
  400. if (commandRowStyle == null) {
  401. commandRowStyle = new TableItemStyle ();
  402. if (IsTrackingViewState)
  403. commandRowStyle.TrackViewState();
  404. }
  405. return commandRowStyle;
  406. }
  407. }
  408. [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
  409. [BrowsableAttribute (false)]
  410. public DetailsViewMode CurrentMode {
  411. get {
  412. return currentMode;
  413. }
  414. }
  415. [DefaultValueAttribute (DetailsViewMode.ReadOnly)]
  416. [WebCategoryAttribute ("Behavior")]
  417. public virtual DetailsViewMode DefaultMode {
  418. get {
  419. object o = ViewState ["DefaultMode"];
  420. if (o != null) return (DetailsViewMode) o;
  421. return DetailsViewMode.ReadOnly;
  422. }
  423. set {
  424. ViewState ["DefaultMode"] = value;
  425. RequireBinding ();
  426. }
  427. }
  428. [EditorAttribute ("System.Web.UI.Design.WebControls.DataControlFieldTypeEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
  429. [MergablePropertyAttribute (false)]
  430. [PersistenceModeAttribute (PersistenceMode.InnerProperty)]
  431. [DefaultValueAttribute (null)]
  432. [WebCategoryAttribute ("Misc")]
  433. public virtual DataControlFieldCollection Fields {
  434. get {
  435. if (columns == null) {
  436. columns = new DataControlFieldCollection ();
  437. columns.FieldsChanged += new EventHandler (OnFieldsChanged);
  438. if (IsTrackingViewState)
  439. ((IStateManager)columns).TrackViewState ();
  440. }
  441. return columns;
  442. }
  443. }
  444. [DefaultValueAttribute (null)]
  445. [WebCategoryAttribute ("Data")]
  446. [TypeConverter (typeof(StringArrayConverter))]
  447. [EditorAttribute ("System.Web.UI.Design.WebControls.DataFieldEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
  448. public virtual string[] DataKeyNames
  449. {
  450. get {
  451. object o = ViewState ["DataKeyNames"];
  452. if (o != null) return (string[]) o;
  453. return emptyKeys;
  454. }
  455. set {
  456. ViewState ["DataKeyNames"] = value;
  457. RequireBinding ();
  458. }
  459. }
  460. [BrowsableAttribute (false)]
  461. [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
  462. public virtual DataKey DataKey {
  463. get {
  464. EnsureDataBound ();
  465. return key;
  466. }
  467. }
  468. [WebCategoryAttribute ("Styles")]
  469. [PersistenceMode (PersistenceMode.InnerProperty)]
  470. [NotifyParentProperty (true)]
  471. [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
  472. [DefaultValueAttribute (null)]
  473. public TableItemStyle EditRowStyle {
  474. get {
  475. if (editRowStyle == null) {
  476. editRowStyle = new TableItemStyle ();
  477. if (IsTrackingViewState)
  478. editRowStyle.TrackViewState();
  479. }
  480. return editRowStyle;
  481. }
  482. }
  483. [WebCategoryAttribute ("Styles")]
  484. [PersistenceMode (PersistenceMode.InnerProperty)]
  485. [NotifyParentProperty (true)]
  486. [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
  487. [DefaultValueAttribute (null)]
  488. public TableItemStyle EmptyDataRowStyle {
  489. get {
  490. if (emptyDataRowStyle == null) {
  491. emptyDataRowStyle = new TableItemStyle ();
  492. if (IsTrackingViewState)
  493. emptyDataRowStyle.TrackViewState();
  494. }
  495. return emptyDataRowStyle;
  496. }
  497. }
  498. [DefaultValue (null)]
  499. [TemplateContainer (typeof(DetailsView), BindingDirection.OneWay)]
  500. [PersistenceMode (PersistenceMode.InnerProperty)]
  501. [Browsable (false)]
  502. public virtual ITemplate EmptyDataTemplate {
  503. get { return emptyDataTemplate; }
  504. set { emptyDataTemplate = value; RequireBinding (); }
  505. }
  506. [LocalizableAttribute (true)]
  507. [WebCategoryAttribute ("Appearance")]
  508. [DefaultValueAttribute ("")]
  509. public virtual string EmptyDataText {
  510. get {
  511. object ob = ViewState ["EmptyDataText"];
  512. if (ob != null) return (string) ob;
  513. return string.Empty;
  514. }
  515. set {
  516. ViewState ["EmptyDataText"] = value;
  517. RequireBinding ();
  518. }
  519. }
  520. [WebCategoryAttribute ("Behavior")]
  521. [DefaultValueAttribute (false)]
  522. public virtual bool EnablePagingCallbacks {
  523. get {
  524. object ob = ViewState ["EnablePagingCallbacks"];
  525. if (ob != null) return (bool) ob;
  526. return false;
  527. }
  528. set {
  529. ViewState ["EnablePagingCallbacks"] = value;
  530. RequireBinding ();
  531. }
  532. }
  533. [WebCategoryAttribute ("Styles")]
  534. [PersistenceMode (PersistenceMode.InnerProperty)]
  535. [NotifyParentProperty (true)]
  536. [DefaultValue (null)]
  537. [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
  538. public TableItemStyle FieldHeaderStyle {
  539. get {
  540. if (fieldHeaderStyle == null) {
  541. fieldHeaderStyle = new TableItemStyle ();
  542. if (IsTrackingViewState)
  543. fieldHeaderStyle.TrackViewState();
  544. }
  545. return fieldHeaderStyle;
  546. }
  547. }
  548. [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
  549. [BrowsableAttribute (false)]
  550. public virtual DetailsViewRow FooterRow {
  551. get {
  552. EnsureChildControls ();
  553. return footerRow;
  554. }
  555. }
  556. [DefaultValue (null)]
  557. [TemplateContainer (typeof(DetailsView), BindingDirection.OneWay)]
  558. [PersistenceMode (PersistenceMode.InnerProperty)]
  559. [Browsable (false)]
  560. public virtual ITemplate FooterTemplate {
  561. get { return footerTemplate; }
  562. set { footerTemplate = value; RequireBinding (); }
  563. }
  564. [LocalizableAttribute (true)]
  565. [WebCategoryAttribute ("Appearance")]
  566. [DefaultValueAttribute ("")]
  567. public virtual string FooterText {
  568. get {
  569. object ob = ViewState ["FooterText"];
  570. if (ob != null) return (string) ob;
  571. return string.Empty;
  572. }
  573. set {
  574. ViewState ["FooterText"] = value;
  575. RequireBinding ();
  576. }
  577. }
  578. [WebCategoryAttribute ("Styles")]
  579. [PersistenceMode (PersistenceMode.InnerProperty)]
  580. [NotifyParentProperty (true)]
  581. [DefaultValue (null)]
  582. [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
  583. public TableItemStyle FooterStyle {
  584. get {
  585. if (footerStyle == null) {
  586. footerStyle = new TableItemStyle ();
  587. if (IsTrackingViewState)
  588. footerStyle.TrackViewState();
  589. }
  590. return footerStyle;
  591. }
  592. }
  593. [WebCategoryAttribute ("Appearance")]
  594. [DefaultValueAttribute (GridLines.Both)]
  595. public virtual GridLines GridLines {
  596. get {
  597. object ob = ViewState ["GridLines"];
  598. if (ob != null) return (GridLines) ob;
  599. return GridLines.Both;
  600. }
  601. set {
  602. ViewState ["GridLines"] = value;
  603. }
  604. }
  605. [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
  606. [BrowsableAttribute (false)]
  607. public virtual DetailsViewRow HeaderRow {
  608. get {
  609. EnsureChildControls ();
  610. return headerRow;
  611. }
  612. }
  613. [WebCategoryAttribute ("Styles")]
  614. [PersistenceMode (PersistenceMode.InnerProperty)]
  615. [NotifyParentProperty (true)]
  616. [DefaultValue (null)]
  617. [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
  618. public TableItemStyle HeaderStyle {
  619. get {
  620. if (headerStyle == null) {
  621. headerStyle = new TableItemStyle ();
  622. if (IsTrackingViewState)
  623. headerStyle.TrackViewState();
  624. }
  625. return headerStyle;
  626. }
  627. }
  628. [DefaultValue (null)]
  629. [TemplateContainer (typeof(DetailsView), BindingDirection.OneWay)]
  630. [PersistenceMode (PersistenceMode.InnerProperty)]
  631. [Browsable (false)]
  632. public virtual ITemplate HeaderTemplate {
  633. get { return headerTemplate; }
  634. set { headerTemplate = value; RequireBinding (); }
  635. }
  636. [LocalizableAttribute (true)]
  637. [WebCategoryAttribute ("Appearance")]
  638. [DefaultValueAttribute ("")]
  639. public virtual string HeaderText {
  640. get {
  641. object ob = ViewState ["HeaderText"];
  642. if (ob != null) return (string) ob;
  643. return string.Empty;
  644. }
  645. set {
  646. ViewState ["HeaderText"] = value;
  647. RequireBinding ();
  648. }
  649. }
  650. [Category ("Layout")]
  651. [DefaultValueAttribute (HorizontalAlign.NotSet)]
  652. public virtual HorizontalAlign HorizontalAlign {
  653. get {
  654. object ob = ViewState ["HorizontalAlign"];
  655. if (ob != null) return (HorizontalAlign) ob;
  656. return HorizontalAlign.NotSet;
  657. }
  658. set {
  659. ViewState ["HorizontalAlign"] = value;
  660. RequireBinding ();
  661. }
  662. }
  663. [WebCategoryAttribute ("Styles")]
  664. [PersistenceMode (PersistenceMode.InnerProperty)]
  665. [NotifyParentProperty (true)]
  666. [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
  667. [DefaultValueAttribute (null)]
  668. public TableItemStyle InsertRowStyle {
  669. get {
  670. if (insertRowStyle == null) {
  671. insertRowStyle = new TableItemStyle ();
  672. if (IsTrackingViewState)
  673. insertRowStyle.TrackViewState();
  674. }
  675. return insertRowStyle;
  676. }
  677. }
  678. [BrowsableAttribute (false)]
  679. [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
  680. public virtual int PageCount {
  681. get {
  682. if (pageCount != -1) return pageCount;
  683. EnsureDataBound ();
  684. return pageCount;
  685. }
  686. }
  687. [WebCategoryAttribute ("Paging")]
  688. [BindableAttribute (true, BindingDirection.OneWay)]
  689. [DefaultValueAttribute (0)]
  690. public virtual int PageIndex {
  691. get {
  692. return pageIndex;
  693. }
  694. set {
  695. pageIndex = value;
  696. RequireBinding ();
  697. }
  698. }
  699. [WebCategoryAttribute ("Paging")]
  700. [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Content)]
  701. [NotifyParentPropertyAttribute (true)]
  702. [PersistenceModeAttribute (PersistenceMode.InnerProperty)]
  703. public virtual PagerSettings PagerSettings {
  704. get {
  705. if (pagerSettings == null) {
  706. pagerSettings = new PagerSettings (this);
  707. if (IsTrackingViewState)
  708. ((IStateManager)pagerSettings).TrackViewState ();
  709. }
  710. return pagerSettings;
  711. }
  712. }
  713. [WebCategoryAttribute ("Styles")]
  714. [PersistenceMode (PersistenceMode.InnerProperty)]
  715. [NotifyParentProperty (true)]
  716. [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
  717. public TableItemStyle PagerStyle {
  718. get {
  719. if (pagerStyle == null) {
  720. pagerStyle = new TableItemStyle ();
  721. if (IsTrackingViewState)
  722. pagerStyle.TrackViewState();
  723. }
  724. return pagerStyle;
  725. }
  726. }
  727. [DefaultValue (null)]
  728. /* DataControlPagerCell isnt specified in the docs */
  729. //[TemplateContainer (typeof(DataControlPagerCell), BindingDirection.OneWay)]
  730. [PersistenceMode (PersistenceMode.InnerProperty)]
  731. [Browsable (false)]
  732. public virtual ITemplate PagerTemplate {
  733. get { return pagerTemplate; }
  734. set { pagerTemplate = value; RequireBinding (); }
  735. }
  736. [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
  737. [BrowsableAttribute (false)]
  738. public virtual DetailsViewRowCollection Rows {
  739. get {
  740. EnsureDataBound ();
  741. return rows;
  742. }
  743. }
  744. [WebCategoryAttribute ("Styles")]
  745. [PersistenceMode (PersistenceMode.InnerProperty)]
  746. [NotifyParentProperty (true)]
  747. [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
  748. [DefaultValue (null)]
  749. public TableItemStyle RowStyle {
  750. get {
  751. if (rowStyle == null) {
  752. rowStyle = new TableItemStyle ();
  753. if (IsTrackingViewState)
  754. rowStyle.TrackViewState();
  755. }
  756. return rowStyle;
  757. }
  758. }
  759. [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
  760. [BrowsableAttribute (false)]
  761. public object SelectedValue {
  762. get { return DataKey.Value; }
  763. }
  764. [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
  765. [BrowsableAttribute (false)]
  766. public virtual DetailsViewRow TopPagerRow {
  767. get {
  768. EnsureDataBound ();
  769. return topPagerRow;
  770. }
  771. }
  772. [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
  773. [BrowsableAttribute (false)]
  774. public virtual object DataItem {
  775. get {
  776. EnsureDataBound ();
  777. return dataItem;
  778. }
  779. }
  780. [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
  781. [BrowsableAttribute (false)]
  782. public int DataItemCount {
  783. get { return PageCount; }
  784. }
  785. [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
  786. [BrowsableAttribute (false)]
  787. public virtual int DataItemIndex {
  788. get { return PageIndex; }
  789. }
  790. int IDataItemContainer.DisplayIndex {
  791. get { return PageIndex; }
  792. }
  793. public virtual bool IsBindableType (Type type)
  794. {
  795. return type.IsPrimitive || type == typeof(string) || type == typeof(DateTime) || type == typeof(Guid);
  796. }
  797. protected override DataSourceSelectArguments CreateDataSourceSelectArguments ()
  798. {
  799. return base.CreateDataSourceSelectArguments ();
  800. }
  801. protected virtual ICollection CreateFieldSet (object dataItem, bool useDataSource)
  802. {
  803. ArrayList fields = new ArrayList ();
  804. if (AutoGenerateRows) {
  805. if (useDataSource) {
  806. if (dataItem != null)
  807. fields.AddRange (CreateAutoGeneratedRows (dataItem));
  808. } else {
  809. if (autoFieldProperties != null) {
  810. foreach (AutoGeneratedFieldProperties props in autoFieldProperties)
  811. fields.Add (CreateAutoGeneratedRow (props));
  812. }
  813. }
  814. }
  815. fields.AddRange (Fields);
  816. if (AutoGenerateEditButton || AutoGenerateDeleteButton || AutoGenerateInsertButton) {
  817. CommandField field = new CommandField ();
  818. field.ShowEditButton = AutoGenerateEditButton;
  819. field.ShowDeleteButton = AutoGenerateDeleteButton;
  820. field.ShowInsertButton = AutoGenerateInsertButton;
  821. fields.Add (field);
  822. commandField = field;
  823. }
  824. return fields;
  825. }
  826. protected virtual ICollection CreateAutoGeneratedRows (object dataItem)
  827. {
  828. ArrayList list = new ArrayList ();
  829. autoFieldProperties = CreateAutoFieldProperties (dataItem);
  830. foreach (AutoGeneratedFieldProperties props in autoFieldProperties)
  831. list.Add (CreateAutoGeneratedRow (props));
  832. return list;
  833. }
  834. protected virtual AutoGeneratedField CreateAutoGeneratedRow (AutoGeneratedFieldProperties fieldProperties)
  835. {
  836. return new AutoGeneratedField (fieldProperties);
  837. }
  838. AutoGeneratedFieldProperties[] CreateAutoFieldProperties (object dataItem)
  839. {
  840. PropertyDescriptorCollection props = TypeDescriptor.GetProperties (dataItem);
  841. ArrayList retVal = new ArrayList();
  842. if (props != null && props.Count > 0)
  843. {
  844. foreach (PropertyDescriptor current in props) {
  845. if (IsBindableType (current.PropertyType)) {
  846. AutoGeneratedFieldProperties field = new AutoGeneratedFieldProperties ();
  847. ((IStateManager)field).TrackViewState();
  848. field.Name = current.Name;
  849. field.DataField = current.Name;
  850. field.IsReadOnly = current.IsReadOnly;
  851. field.Type = current.PropertyType;
  852. retVal.Add (field);
  853. }
  854. }
  855. }
  856. if (retVal.Count > 0)
  857. return (AutoGeneratedFieldProperties[]) retVal.ToArray (typeof(AutoGeneratedFieldProperties));
  858. else
  859. return new AutoGeneratedFieldProperties [0];
  860. }
  861. protected virtual DetailsViewRow CreateRow (int rowIndex, DataControlRowType rowType, DataControlRowState rowState)
  862. {
  863. DetailsViewRow row = new DetailsViewRow (rowIndex, rowType, rowState);
  864. OnItemCreated (EventArgs.Empty);
  865. return row;
  866. }
  867. void RequireBinding ()
  868. {
  869. if (Initialized) {
  870. RequiresDataBinding = true;
  871. pageCount = -1;
  872. }
  873. }
  874. protected virtual Table CreateTable ()
  875. {
  876. Table table = new Table ();
  877. table.Caption = Caption;
  878. table.CaptionAlign = CaptionAlign;
  879. table.CellPadding = CellPadding;
  880. table.CellSpacing = CellSpacing;
  881. table.HorizontalAlign = HorizontalAlign;
  882. table.BackImageUrl = BackImageUrl;
  883. return table;
  884. }
  885. [MonoTODO]
  886. protected override Style CreateControlStyle ()
  887. {
  888. throw new NotImplementedException ();
  889. }
  890. protected override int CreateChildControls (IEnumerable data, bool dataBinding)
  891. {
  892. PagedDataSource dataSource;
  893. if (dataBinding) {
  894. DataSourceView view = GetData ();
  895. dataSource = new PagedDataSource ();
  896. dataSource.DataSource = data;
  897. if (AllowPaging) {
  898. dataSource.AllowPaging = true;
  899. dataSource.PageSize = 1;
  900. dataSource.CurrentPageIndex = PageIndex;
  901. if (view.CanPage) {
  902. dataSource.AllowServerPaging = true;
  903. if (view.CanRetrieveTotalRowCount)
  904. dataSource.VirtualCount = SelectArguments.TotalRowCount;
  905. else {
  906. dataSource.DataSourceView = view;
  907. dataSource.DataSourceSelectArguments = SelectArguments;
  908. dataSource.SetItemCountFromPageIndex (PageIndex + PagerSettings.PageButtonCount);
  909. }
  910. }
  911. }
  912. pageCount = dataSource.PageCount;
  913. }
  914. else
  915. {
  916. dataSource = new PagedDataSource ();
  917. dataSource.DataSource = data;
  918. if (AllowPaging) {
  919. dataSource.AllowPaging = true;
  920. dataSource.PageSize = 1;
  921. dataSource.CurrentPageIndex = PageIndex;
  922. }
  923. }
  924. bool showPager = AllowPaging && (PageCount > 1);
  925. Controls.Clear ();
  926. table = CreateTable ();
  927. Controls.Add (table);
  928. ArrayList list = new ArrayList ();
  929. if (!Page.IsPostBack)
  930. currentMode = DefaultMode;
  931. // Gets the current data item
  932. IEnumerator e = dataSource.GetEnumerator ();
  933. if (e.MoveNext ())
  934. dataItem = e.Current;
  935. else
  936. dataItem = null;
  937. // Creates the set of fields to show
  938. ICollection fieldCollection = CreateFieldSet (dataItem, dataBinding);
  939. DataControlField[] fields = new DataControlField [fieldCollection.Count];
  940. fieldCollection.CopyTo (fields, 0);
  941. foreach (DataControlField field in fields) {
  942. field.Initialize (false, this);
  943. if (EnablePagingCallbacks)
  944. field.ValidateSupportsCallback ();
  945. }
  946. // Main table creation
  947. if (HeaderText.Length != 0 || headerTemplate != null) {
  948. headerRow = CreateRow (-1, DataControlRowType.Header, DataControlRowState.Normal);
  949. DataControlFieldCell cell = new DataControlFieldCell (null);
  950. cell.ColumnSpan = 2;
  951. if (headerTemplate != null)
  952. headerTemplate.InstantiateIn (cell);
  953. else
  954. cell.Text = HeaderText;
  955. headerRow.Cells.Add (cell);
  956. table.Rows.Add (headerRow);
  957. }
  958. if (showPager && PagerSettings.Position == PagerPosition.Top || PagerSettings.Position == PagerPosition.TopAndBottom) {
  959. topPagerRow = CreateRow (-1, DataControlRowType.Pager, DataControlRowState.Normal);
  960. InitializePager (topPagerRow, dataSource);
  961. table.Rows.Add (topPagerRow);
  962. }
  963. if (dataSource.Count > 0) {
  964. foreach (DataControlField field in fields) {
  965. DataControlRowState rstate = GetRowState (list.Count);
  966. DetailsViewRow row = CreateRow (list.Count, DataControlRowType.DataRow, rstate);
  967. InitializeRow (row, field);
  968. table.Rows.Add (row);
  969. list.Add (row);
  970. if (commandField == field)
  971. commandRow = row;
  972. }
  973. if (!dataBinding) {
  974. if (CurrentMode == DetailsViewMode.Edit)
  975. oldEditValues = new DataKey (new OrderedDictionary ());
  976. key = new DataKey (new OrderedDictionary (), DataKeyNames);
  977. }
  978. } else {
  979. table.Rows.Add (CreateEmptyrRow ());
  980. }
  981. rows = new DetailsViewRowCollection (list);
  982. if (showPager && PagerSettings.Position == PagerPosition.Bottom || PagerSettings.Position == PagerPosition.TopAndBottom) {
  983. bottomPagerRow = CreateRow (-1, DataControlRowType.Pager, DataControlRowState.Normal);
  984. InitializePager (bottomPagerRow, dataSource);
  985. table.Rows.Add (bottomPagerRow);
  986. }
  987. if (FooterText.Length != 0 || footerTemplate != null) {
  988. footerRow = CreateRow (-1, DataControlRowType.Footer, DataControlRowState.Normal);
  989. DataControlFieldCell cell = new DataControlFieldCell (null);
  990. cell.ColumnSpan = 2;
  991. if (footerTemplate != null)
  992. footerTemplate.InstantiateIn (cell);
  993. else
  994. cell.Text = FooterText;
  995. footerRow.Cells.Add (cell);
  996. table.Rows.Add (footerRow);
  997. }
  998. if (dataBinding)
  999. DataBind (false);
  1000. return dataSource.DataSourceCount;
  1001. }
  1002. [MonoTODO]
  1003. protected override void EnsureDataBound ()
  1004. {
  1005. throw new NotImplementedException ();
  1006. }
  1007. DataControlRowState GetRowState (int index)
  1008. {
  1009. DataControlRowState rstate = (index % 2) == 0 ? DataControlRowState.Normal : DataControlRowState.Alternate;
  1010. if (CurrentMode == DetailsViewMode.Edit) rstate |= DataControlRowState.Edit;
  1011. else if (CurrentMode == DetailsViewMode.Insert) rstate |= DataControlRowState.Insert;
  1012. return rstate;
  1013. }
  1014. protected virtual void InitializePager (DetailsViewRow row, PagedDataSource dataSource)
  1015. {
  1016. TableCell cell = new TableCell ();
  1017. cell.ColumnSpan = 2;
  1018. if (pagerTemplate != null)
  1019. pagerTemplate.InstantiateIn (cell);
  1020. else
  1021. cell.Controls.Add (PagerSettings.CreatePagerControl (dataSource.CurrentPageIndex, dataSource.PageCount));
  1022. row.Cells.Add (cell);
  1023. }
  1024. DetailsViewRow CreateEmptyrRow ()
  1025. {
  1026. DetailsViewRow row = CreateRow (-1, DataControlRowType.EmptyDataRow, DataControlRowState.Normal);
  1027. TableCell cell = new TableCell ();
  1028. cell.ColumnSpan = 2;
  1029. if (emptyDataTemplate != null)
  1030. emptyDataTemplate.InstantiateIn (cell);
  1031. else
  1032. cell.Text = EmptyDataText;
  1033. row.Cells.Add (cell);
  1034. return row;
  1035. }
  1036. protected virtual void InitializeRow (DetailsViewRow row, DataControlField field)
  1037. {
  1038. DataControlFieldCell cell;
  1039. if (field.ShowHeader) {
  1040. cell = new DataControlFieldCell (field);
  1041. row.Cells.Add (cell);
  1042. field.InitializeCell (cell, DataControlCellType.Header, row.RowState, row.RowIndex);
  1043. }
  1044. cell = new DataControlFieldCell (field);
  1045. if (!field.ShowHeader)
  1046. cell.ColumnSpan = 2;
  1047. row.Cells.Add (cell);
  1048. field.InitializeCell (cell, DataControlCellType.DataCell, row.RowState, row.RowIndex);
  1049. }
  1050. IOrderedDictionary CreateRowDataKey (object dataItem)
  1051. {
  1052. if (cachedKeyProperties == null) {
  1053. PropertyDescriptorCollection props = TypeDescriptor.GetProperties (dataItem);
  1054. cachedKeyProperties = new PropertyDescriptor [DataKeyNames.Length];
  1055. for (int n=0; n<DataKeyNames.Length; n++) {
  1056. PropertyDescriptor p = props [DataKeyNames[n]];
  1057. if (p == null)
  1058. new InvalidOperationException ("Property '" + DataKeyNames[n] + "' not found in object of type " + dataItem.GetType());
  1059. cachedKeyProperties [n] = p;
  1060. }
  1061. }
  1062. OrderedDictionary dic = new OrderedDictionary ();
  1063. foreach (PropertyDescriptor p in cachedKeyProperties)
  1064. dic [p.Name] = p.GetValue (dataItem);
  1065. return dic;
  1066. }
  1067. IOrderedDictionary GetRowValues (bool includeReadOnlyFields, bool includePrimaryKey)
  1068. {
  1069. OrderedDictionary dic = new OrderedDictionary ();
  1070. ExtractRowValues (dic, includeReadOnlyFields, includePrimaryKey);
  1071. return dic;
  1072. }
  1073. protected virtual void ExtractRowValues (IOrderedDictionary fieldValues, bool includeReadOnlyFields, bool includePrimaryKey)
  1074. {
  1075. foreach (DetailsViewRow row in Rows) {
  1076. if (row.Cells.Count < 1) continue;
  1077. DataControlFieldCell c = row.Cells[row.Cells.Count-1] as DataControlFieldCell;
  1078. if (c != null)
  1079. c.ContainingField.ExtractValuesFromCell (fieldValues, c, row.RowState, includeReadOnlyFields);
  1080. }
  1081. if (!includePrimaryKey && DataKeyNames != null)
  1082. foreach (string key in DataKeyNames)
  1083. fieldValues.Remove (key);
  1084. }
  1085. protected override HtmlTextWriterTag TagKey {
  1086. get {
  1087. if (EnablePagingCallbacks)
  1088. return HtmlTextWriterTag.Div;
  1089. else
  1090. return HtmlTextWriterTag.Table;
  1091. }
  1092. }
  1093. public sealed override void DataBind ()
  1094. {
  1095. DataSourceView view = GetData ();
  1096. if (AllowPaging && view.CanPage) {
  1097. SelectArguments.StartRowIndex = PageIndex;
  1098. SelectArguments.MaximumRows = 1;
  1099. if (view.CanRetrieveTotalRowCount)
  1100. SelectArguments.RetrieveTotalRowCount = true;
  1101. }
  1102. cachedKeyProperties = null;
  1103. base.DataBind ();
  1104. if (dataItem != null) {
  1105. if (CurrentMode == DetailsViewMode.Edit)
  1106. oldEditValues = new DataKey (GetRowValues (false, true));
  1107. key = new DataKey (CreateRowDataKey (dataItem), DataKeyNames);
  1108. }
  1109. }
  1110. protected internal override void PerformDataBinding (IEnumerable data)
  1111. {
  1112. base.PerformDataBinding (data);
  1113. }
  1114. [MonoTODO]
  1115. protected internal virtual void PrepareControlHierarchy ()
  1116. {
  1117. throw new NotImplementedException ();
  1118. }
  1119. protected internal override void OnInit (EventArgs e)
  1120. {
  1121. Page.RegisterRequiresControlState (this);
  1122. base.OnInit (e);
  1123. }
  1124. void OnFieldsChanged (object sender, EventArgs args)
  1125. {
  1126. RequireBinding ();
  1127. }
  1128. protected override void OnDataSourceViewChanged (object sender, EventArgs e)
  1129. {
  1130. base.OnDataSourceViewChanged (sender, e);
  1131. RequireBinding ();
  1132. }
  1133. protected override bool OnBubbleEvent (object source, EventArgs e)
  1134. {
  1135. DetailsViewCommandEventArgs args = e as DetailsViewCommandEventArgs;
  1136. if (args != null) {
  1137. OnItemCommand (args);
  1138. ProcessEvent (args.CommandName, args.CommandArgument as string);
  1139. }
  1140. return base.OnBubbleEvent (source, e);
  1141. }
  1142. void IPostBackEventHandler.RaisePostBackEvent (string eventArgument)
  1143. {
  1144. RaisePostBackEvent (eventArgument);
  1145. }
  1146. // TODO: This is prolly obsolete
  1147. protected virtual void RaisePostBackEvent (string eventArgument)
  1148. {
  1149. int i = eventArgument.IndexOf ('$');
  1150. if (i != -1)
  1151. ProcessEvent (eventArgument.Substring (0, i), eventArgument.Substring (i + 1));
  1152. else
  1153. ProcessEvent (eventArgument, null);
  1154. }
  1155. void ProcessEvent (string eventName, string param)
  1156. {
  1157. switch (eventName)
  1158. {
  1159. case DataControlCommands.PageCommandName:
  1160. int newIndex = -1;
  1161. switch (param) {
  1162. case DataControlCommands.FirstPageCommandArgument:
  1163. newIndex = 0;
  1164. break;
  1165. case DataControlCommands.LastPageCommandArgument:
  1166. newIndex = PageCount - 1;
  1167. break;
  1168. case DataControlCommands.NextPageCommandArgument:
  1169. if (PageIndex < PageCount - 1) newIndex = PageIndex + 1;
  1170. break;
  1171. case DataControlCommands.PreviousPageCommandArgument:
  1172. if (PageIndex > 0) newIndex = PageIndex - 1;
  1173. break;
  1174. default:
  1175. newIndex = int.Parse (param) - 1;
  1176. break;
  1177. }
  1178. ShowPage (newIndex);
  1179. break;
  1180. case DataControlCommands.FirstPageCommandArgument:
  1181. ShowPage (0);
  1182. break;
  1183. case DataControlCommands.LastPageCommandArgument:
  1184. ShowPage (PageCount - 1);
  1185. break;
  1186. case DataControlCommands.NextPageCommandArgument:
  1187. if (PageIndex < PageCount - 1)
  1188. ShowPage (PageIndex + 1);
  1189. break;
  1190. case DataControlCommands.PreviousPageCommandArgument:
  1191. if (PageIndex > 0)
  1192. ShowPage (PageIndex - 1);
  1193. break;
  1194. case DataControlCommands.EditCommandName:
  1195. ChangeMode (DetailsViewMode.Edit);
  1196. break;
  1197. case DataControlCommands.NewCommandName:
  1198. ChangeMode (DetailsViewMode.Insert);
  1199. break;
  1200. case DataControlCommands.UpdateCommandName:
  1201. UpdateItem (param, true);
  1202. break;
  1203. case DataControlCommands.CancelCommandName:
  1204. CancelEdit ();
  1205. break;
  1206. case DataControlCommands.DeleteCommandName:
  1207. DeleteItem ();
  1208. break;
  1209. case DataControlCommands.InsertCommandName:
  1210. InsertItem (true);
  1211. break;
  1212. }
  1213. }
  1214. void ShowPage (int newIndex)
  1215. {
  1216. DetailsViewPageEventArgs args = new DetailsViewPageEventArgs (newIndex);
  1217. OnPageIndexChanging (args);
  1218. if (!args.Cancel) {
  1219. EndRowEdit ();
  1220. PageIndex = args.NewPageIndex;
  1221. OnPageIndexChanged (EventArgs.Empty);
  1222. }
  1223. }
  1224. public void ChangeMode (DetailsViewMode newMode)
  1225. {
  1226. DetailsViewModeEventArgs args = new DetailsViewModeEventArgs (newMode, false);
  1227. OnModeChanging (args);
  1228. if (!args.Cancel) {
  1229. currentMode = args.NewMode;
  1230. OnModeChanged (EventArgs.Empty);
  1231. RequireBinding ();
  1232. }
  1233. }
  1234. void CancelEdit ()
  1235. {
  1236. DetailsViewModeEventArgs args = new DetailsViewModeEventArgs (DetailsViewMode.ReadOnly, true);
  1237. OnModeChanging (args);
  1238. if (!args.Cancel) {
  1239. EndRowEdit ();
  1240. }
  1241. }
  1242. public virtual void UpdateItem (bool causesValidation)
  1243. {
  1244. UpdateItem (null, causesValidation);
  1245. }
  1246. void UpdateItem (string param, bool causesValidation)
  1247. {
  1248. if (causesValidation)
  1249. Page.Validate ();
  1250. if (currentMode != DetailsViewMode.Edit) throw new NotSupportedException ();
  1251. currentEditOldValues = oldEditValues.Values;
  1252. currentEditRowKeys = DataKey.Values;
  1253. currentEditNewValues = GetRowValues (false, false);
  1254. DetailsViewUpdateEventArgs args = new DetailsViewUpdateEventArgs (param, currentEditRowKeys, currentEditOldValues, currentEditNewValues);
  1255. OnItemUpdating (args);
  1256. if (!args.Cancel) {
  1257. DataSourceView view = GetData ();
  1258. if (view == null) throw new HttpException ("The DataSourceView associated to data bound control was null");
  1259. view.Update (currentEditRowKeys, currentEditNewValues, currentEditOldValues, new DataSourceViewOperationCallback (UpdateCallback));
  1260. } else
  1261. EndRowEdit ();
  1262. }
  1263. bool UpdateCallback (int recordsAffected, Exception exception)
  1264. {
  1265. DetailsViewUpdatedEventArgs dargs = new DetailsViewUpdatedEventArgs (recordsAffected, exception, currentEditRowKeys, currentEditOldValues, currentEditNewValues);
  1266. OnItemUpdated (dargs);
  1267. if (!dargs.KeepInEditMode)
  1268. EndRowEdit ();
  1269. return dargs.ExceptionHandled;
  1270. }
  1271. public virtual void InsertItem (bool causesValidation)
  1272. {
  1273. InsertItem (null, causesValidation);
  1274. }
  1275. void InsertItem (string param, bool causesValidation)
  1276. {
  1277. if (causesValidation)
  1278. Page.Validate ();
  1279. if (currentMode != DetailsViewMode.Insert) throw new NotSupportedException ();
  1280. currentEditNewValues = GetRowValues (false, true);
  1281. DetailsViewInsertEventArgs args = new DetailsViewInsertEventArgs (param, currentEditNewValues);
  1282. OnItemInserting (args);
  1283. if (!args.Cancel) {
  1284. DataSourceView view = GetData ();
  1285. if (view == null) throw new HttpException ("The DataSourceView associated to data bound control was null");
  1286. view.Insert (currentEditNewValues, new DataSourceViewOperationCallback (InsertCallback));
  1287. } else
  1288. EndRowEdit ();
  1289. }
  1290. bool InsertCallback (int recordsAffected, Exception exception)
  1291. {
  1292. DetailsViewInsertedEventArgs dargs = new DetailsViewInsertedEventArgs (recordsAffected, exception, currentEditNewValues);
  1293. OnItemInserted (dargs);
  1294. if (!dargs.KeepInInsertMode)
  1295. EndRowEdit ();
  1296. return dargs.ExceptionHandled;
  1297. }
  1298. public virtual void DeleteItem ()
  1299. {
  1300. currentEditRowKeys = DataKey.Values;
  1301. currentEditNewValues = GetRowValues (true, true);
  1302. DetailsViewDeleteEventArgs args = new DetailsViewDeleteEventArgs (PageIndex, currentEditRowKeys, currentEditNewValues);
  1303. OnItemDeleting (args);
  1304. if (!args.Cancel) {
  1305. if (PageIndex == PageCount - 1)
  1306. PageIndex --;
  1307. RequireBinding ();
  1308. DataSourceView view = GetData ();
  1309. if (view != null)
  1310. view.Delete (currentEditRowKeys, currentEditNewValues, new DataSourceViewOperationCallback (DeleteCallback));
  1311. else {
  1312. DetailsViewDeletedEventArgs dargs = new DetailsViewDeletedEventArgs (0, null, currentEditRowKeys, currentEditNewValues);
  1313. OnItemDeleted (dargs);
  1314. }
  1315. }
  1316. }
  1317. bool DeleteCallback (int recordsAffected, Exception exception)
  1318. {
  1319. DetailsViewDeletedEventArgs dargs = new DetailsViewDeletedEventArgs (recordsAffected, exception, currentEditRowKeys, currentEditNewValues);
  1320. OnItemDeleted (dargs);
  1321. return dargs.ExceptionHandled;
  1322. }
  1323. void EndRowEdit ()
  1324. {
  1325. ChangeMode (DefaultMode);
  1326. oldEditValues = new DataKey (new OrderedDictionary ());
  1327. currentEditRowKeys = null;
  1328. currentEditOldValues = null;
  1329. currentEditNewValues = null;
  1330. RequireBinding ();
  1331. }
  1332. protected internal override void LoadControlState (object ob)
  1333. {
  1334. if (ob == null) return;
  1335. object[] state = (object[]) ob;
  1336. base.LoadControlState (state[0]);
  1337. pageIndex = (int) state[1];
  1338. pageCount = (int) state[2];
  1339. currentMode = (DetailsViewMode) state[3];
  1340. }
  1341. protected internal override object SaveControlState ()
  1342. {
  1343. object bstate = base.SaveControlState ();
  1344. return new object[] {
  1345. bstate, pageIndex, pageCount, currentMode
  1346. };
  1347. }
  1348. protected override void TrackViewState()
  1349. {
  1350. base.TrackViewState();
  1351. if (columns != null) ((IStateManager)columns).TrackViewState();
  1352. if (pagerSettings != null) ((IStateManager)pagerSettings).TrackViewState();
  1353. if (alternatingRowStyle != null) ((IStateManager)alternatingRowStyle).TrackViewState();
  1354. if (footerStyle != null) ((IStateManager)footerStyle).TrackViewState();
  1355. if (headerStyle != null) ((IStateManager)headerStyle).TrackViewState();
  1356. if (pagerStyle != null) ((IStateManager)pagerStyle).TrackViewState();
  1357. if (rowStyle != null) ((IStateManager)rowStyle).TrackViewState();
  1358. if (editRowStyle != null) ((IStateManager)editRowStyle).TrackViewState();
  1359. if (insertRowStyle != null) ((IStateManager)insertRowStyle).TrackViewState();
  1360. if (emptyDataRowStyle != null) ((IStateManager)emptyDataRowStyle).TrackViewState();
  1361. if (key != null) ((IStateManager)key).TrackViewState();
  1362. if (autoFieldProperties != null) {
  1363. foreach (IStateManager sm in autoFieldProperties)
  1364. sm.TrackViewState ();
  1365. }
  1366. }
  1367. protected override object SaveViewState()
  1368. {
  1369. object[] states = new object [14];
  1370. states[0] = base.SaveViewState();
  1371. states[1] = (columns == null ? null : ((IStateManager)columns).SaveViewState());
  1372. states[2] = (pagerSettings == null ? null : ((IStateManager)pagerSettings).SaveViewState());
  1373. states[3] = (alternatingRowStyle == null ? null : ((IStateManager)alternatingRowStyle).SaveViewState());
  1374. states[4] = (footerStyle == null ? null : ((IStateManager)footerStyle).SaveViewState());
  1375. states[5] = (headerStyle == null ? null : ((IStateManager)headerStyle).SaveViewState());
  1376. states[6] = (pagerStyle == null ? null : ((IStateManager)pagerStyle).SaveViewState());
  1377. states[7] = (rowStyle == null ? null : ((IStateManager)rowStyle).SaveViewState());
  1378. states[8] = (insertRowStyle == null ? null : ((IStateManager)insertRowStyle).SaveViewState());
  1379. states[9] = (editRowStyle == null ? null : ((IStateManager)editRowStyle).SaveViewState());
  1380. states[10] = (emptyDataRowStyle == null ? null : ((IStateManager)emptyDataRowStyle).SaveViewState());
  1381. states[11] = (key == null ? null : ((IStateManager)key).SaveViewState());
  1382. states[12] = (oldEditValues == null ? null : ((IStateManager)oldEditValues).SaveViewState());
  1383. if (autoFieldProperties != null) {
  1384. object[] data = new object [autoFieldProperties.Length];
  1385. bool allNull = true;
  1386. for (int n=0; n<data.Length; n++) {
  1387. data [n] = ((IStateManager)autoFieldProperties [n]).SaveViewState ();
  1388. if (data [n] != null) allNull = false;
  1389. }
  1390. if (!allNull) states [13] = data;
  1391. }
  1392. for (int i = states.Length - 1; i >= 0; i--) {
  1393. if (states [i] != null)
  1394. return states;
  1395. }
  1396. return null;
  1397. }
  1398. protected override void LoadViewState (object savedState)
  1399. {
  1400. if (savedState == null) {
  1401. base.LoadViewState (null);
  1402. return;
  1403. }
  1404. object [] states = (object []) savedState;
  1405. if (states[13] != null) {
  1406. object[] data = (object[]) states [13];
  1407. autoFieldProperties = new AutoGeneratedFieldProperties [data.Length];
  1408. for (int n=0; n<data.Length; n++) {
  1409. IStateManager p = new AutoGeneratedFieldProperties ();
  1410. p.TrackViewState ();
  1411. p.LoadViewState (data [n]);
  1412. autoFieldProperties [n] = (AutoGeneratedFieldProperties) p;
  1413. }
  1414. }
  1415. base.LoadViewState (states[0]);
  1416. EnsureChildControls ();
  1417. if (states[1] != null) ((IStateManager)Fields).LoadViewState (states[1]);
  1418. if (states[2] != null) ((IStateManager)PagerSettings).LoadViewState (states[2]);
  1419. if (states[3] != null) ((IStateManager)AlternatingRowStyle).LoadViewState (states[3]);
  1420. if (states[4] != null) ((IStateManager)FooterStyle).LoadViewState (states[4]);
  1421. if (states[5] != null) ((IStateManager)HeaderStyle).LoadViewState (states[5]);
  1422. if (states[6] != null) ((IStateManager)PagerStyle).LoadViewState (states[6]);
  1423. if (states[7] != null) ((IStateManager)RowStyle).LoadViewState (states[7]);
  1424. if (states[8] != null) ((IStateManager)InsertRowStyle).LoadViewState (states[8]);
  1425. if (states[9] != null) ((IStateManager)EditRowStyle).LoadViewState (states[9]);
  1426. if (states[10] != null) ((IStateManager)EmptyDataRowStyle).LoadViewState (states[10]);
  1427. if (states[11] != null) ((IStateManager)DataKey).LoadViewState (states[11]);
  1428. if (states[12] != null && oldEditValues != null) ((IStateManager)oldEditValues).LoadViewState (states[12]);
  1429. }
  1430. void ICallbackEventHandler.RaiseCallbackEvent (string eventArgs)
  1431. {
  1432. RaiseCallbackEvent (eventArgs);
  1433. }
  1434. string callbackResult;
  1435. protected virtual void RaiseCallbackEvent (string eventArgs)
  1436. {
  1437. string[] clientData = eventArgs.Split ('|');
  1438. pageIndex = int.Parse (clientData[0]);
  1439. RequireBinding ();
  1440. RaisePostBackEvent (clientData[2]);
  1441. EnsureDataBound ();
  1442. StringWriter sw = new StringWriter ();
  1443. sw.Write (PageIndex.ToString());
  1444. HtmlTextWriter writer = new HtmlTextWriter (sw);
  1445. RenderGrid (writer);
  1446. callbackResult = sw.ToString ();
  1447. }
  1448. string ICallbackEventHandler.GetCallbackResult ()
  1449. {
  1450. return GetCallbackResult ();
  1451. }
  1452. protected virtual string GetCallbackResult ()
  1453. {
  1454. return callbackResult;
  1455. }
  1456. [MonoTODO]
  1457. protected virtual string GetCallbackScript (IButtonControl buttonControl, string argument)
  1458. {
  1459. throw new NotImplementedException ();
  1460. }
  1461. string ICallbackContainer.GetCallbackScript (IButtonControl control, string argument)
  1462. {
  1463. if (EnablePagingCallbacks)
  1464. return "javascript:GridView_ClientEvent (\"" + ClientID + "\",\"" + control.CommandName + "$" + control.CommandArgument + "\"); return false;";
  1465. else
  1466. return null;
  1467. }
  1468. [MonoTODO]
  1469. protected override void OnPagePreLoad (object sender, EventArgs e)
  1470. {
  1471. throw new NotImplementedException ();
  1472. }
  1473. protected internal override void OnPreRender (EventArgs e)
  1474. {
  1475. base.OnPreRender (e);
  1476. if (EnablePagingCallbacks)
  1477. {
  1478. if (!Page.ClientScript.IsClientScriptIncludeRegistered (typeof(GridView), "GridView.js")) {
  1479. string url = Page.ClientScript.GetWebResourceUrl (typeof(GridView), "GridView.js");
  1480. Page.ClientScript.RegisterClientScriptInclude (typeof(GridView), "GridView.js", url);
  1481. }
  1482. string cgrid = ClientID + "_data";
  1483. string script = string.Format ("var {0} = new Object ();\n", cgrid);
  1484. script += string.Format ("{0}.pageIndex = {1};\n", cgrid, ClientScriptManager.GetScriptLiteral (PageIndex));
  1485. script += string.Format ("{0}.uid = {1};\n", cgrid, ClientScriptManager.GetScriptLiteral (UniqueID));
  1486. Page.ClientScript.RegisterStartupScript (typeof(TreeView), this.UniqueID, script, true);
  1487. // Make sure the basic script infrastructure is rendered
  1488. Page.ClientScript.GetCallbackEventReference (this, "null", "", "null");
  1489. Page.ClientScript.GetPostBackClientHyperlink (this, "");
  1490. }
  1491. }
  1492. protected internal override void Render (HtmlTextWriter writer)
  1493. {
  1494. if (EnablePagingCallbacks)
  1495. base.RenderBeginTag (writer);
  1496. RenderGrid (writer);
  1497. if (EnablePagingCallbacks)
  1498. base.RenderEndTag (writer);
  1499. }
  1500. void RenderGrid (HtmlTextWriter writer)
  1501. {
  1502. switch (GridLines) {
  1503. case GridLines.Horizontal:
  1504. writer.AddAttribute (HtmlTextWriterAttribute.Rules, "rows");
  1505. writer.AddAttribute (HtmlTextWriterAttribute.Border, "1");
  1506. break;
  1507. case GridLines.Vertical:
  1508. writer.AddAttribute (HtmlTextWriterAttribute.Rules, "cols");
  1509. writer.AddAttribute (HtmlTextWriterAttribute.Border, "1");
  1510. break;
  1511. case GridLines.Both:
  1512. writer.AddAttribute (HtmlTextWriterAttribute.Rules, "all");
  1513. writer.AddAttribute (HtmlTextWriterAttribute.Border, "1");
  1514. break;
  1515. default:
  1516. writer.AddAttribute (HtmlTextWriterAttribute.Border, "0");
  1517. break;
  1518. }
  1519. writer.AddAttribute (HtmlTextWriterAttribute.Cellspacing, "0");
  1520. writer.AddStyleAttribute (HtmlTextWriterStyle.BorderCollapse, "collapse");
  1521. table.RenderBeginTag (writer);
  1522. foreach (DetailsViewRow row in table.Rows)
  1523. {
  1524. switch (row.RowType) {
  1525. case DataControlRowType.Header:
  1526. if (headerStyle != null)headerStyle.AddAttributesToRender (writer, row);
  1527. break;
  1528. case DataControlRowType.Footer:
  1529. if (footerStyle != null) footerStyle.AddAttributesToRender (writer, row);
  1530. break;
  1531. case DataControlRowType.Pager:
  1532. if (pagerStyle != null) pagerStyle.AddAttributesToRender (writer, row);
  1533. break;
  1534. case DataControlRowType.EmptyDataRow:
  1535. if (emptyDataRowStyle != null) emptyDataRowStyle.AddAttributesToRender (writer, row);
  1536. break;
  1537. default:
  1538. if (rowStyle != null) rowStyle.AddAttributesToRender (writer, row);
  1539. break;
  1540. }
  1541. if ((row.RowState & DataControlRowState.Alternate) != 0 && alternatingRowStyle != null)
  1542. alternatingRowStyle.AddAttributesToRender (writer, row);
  1543. if ((row.RowState & DataControlRowState.Edit) != 0 && editRowStyle != null)
  1544. editRowStyle.AddAttributesToRender (writer, row);
  1545. if ((row.RowState & DataControlRowState.Insert) != 0 && insertRowStyle != null)
  1546. insertRowStyle.AddAttributesToRender (writer, row);
  1547. if (row == commandRow && commandRowStyle != null)
  1548. commandRowStyle.AddAttributesToRender (writer, row);
  1549. row.RenderBeginTag (writer);
  1550. for (int n=0; n<row.Cells.Count; n++) {
  1551. DataControlFieldCell fcell = row.Cells[n] as DataControlFieldCell;
  1552. if (fcell != null && fcell.ContainingField != null) {
  1553. if (n == 0 && fcell.ContainingField.ShowHeader) {
  1554. if (fieldHeaderStyle != null)
  1555. fieldHeaderStyle.AddAttributesToRender (writer, fcell);
  1556. fcell.ContainingField.HeaderStyle.AddAttributesToRender (writer, fcell);
  1557. }
  1558. else
  1559. fcell.ContainingField.ItemStyle.AddAttributesToRender (writer, fcell);
  1560. }
  1561. row.Cells[n].Render (writer);
  1562. }
  1563. row.RenderEndTag (writer);
  1564. }
  1565. table.RenderEndTag (writer);
  1566. }
  1567. [MonoTODO]
  1568. PostBackOptions IPostBackContainer.GetPostBackOptions (IButtonControl control)
  1569. {
  1570. throw new NotImplementedException ();
  1571. }
  1572. }
  1573. }
  1574. #endif