DetailsView.cs 55 KB

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