2 // System.Web.UI.WebControls.FormView.cs
5 // Lluis Sanchez Gual (lluis@novell.com)
7 // (C) 2005-2010 Novell, Inc (http://www.novell.com)
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:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
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.
30 using System.Collections;
31 using System.Collections.Specialized;
32 using System.ComponentModel;
34 using System.Security.Permissions;
37 using System.Reflection;
39 namespace System.Web.UI.WebControls
41 [SupportsEventValidation]
42 [DesignerAttribute ("System.Web.UI.Design.WebControls.FormViewDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
43 [ControlValuePropertyAttribute ("SelectedValue")]
44 [DefaultEventAttribute ("PageIndexChanging")]
46 [DataKeyProperty ("DataKey")]
48 [AspNetHostingPermissionAttribute (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
49 [AspNetHostingPermissionAttribute (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
50 public class FormView: CompositeDataBoundControl, IDataItemContainer, INamingContainer, IPostBackEventHandler, IPostBackContainer
52 , IDataBoundItemControl, IDataBoundControl, IRenderOuterTable
58 FormViewRow headerRow;
59 FormViewRow footerRow;
60 FormViewRow bottomPagerRow;
61 FormViewRow topPagerRow;
64 IOrderedDictionary currentEditRowKeys;
65 IOrderedDictionary currentEditNewValues;
66 IOrderedDictionary currentEditOldValues;
68 ITemplate pagerTemplate;
69 ITemplate emptyDataTemplate;
70 ITemplate headerTemplate;
71 ITemplate footerTemplate;
72 ITemplate editItemTemplate;
73 ITemplate insertItemTemplate;
74 ITemplate itemTemplate;
76 PropertyDescriptor[] cachedKeyProperties;
77 readonly string[] emptyKeys = new string[0];
78 readonly string unhandledEventExceptionMessage = "The FormView '{0}' fired event {1} which wasn't handled.";
81 PagerSettings pagerSettings;
83 TableItemStyle editRowStyle;
84 TableItemStyle insertRowStyle;
85 TableItemStyle emptyDataRowStyle;
86 TableItemStyle footerStyle;
87 TableItemStyle headerStyle;
88 TableItemStyle pagerStyle;
89 TableItemStyle rowStyle;
91 IOrderedDictionary _keyTable;
93 DataKey oldEditValues;
95 bool renderOuterTable = true;
97 static readonly object PageIndexChangedEvent = new object();
98 static readonly object PageIndexChangingEvent = new object();
99 static readonly object ItemCommandEvent = new object();
100 static readonly object ItemCreatedEvent = new object();
101 static readonly object ItemDeletedEvent = new object();
102 static readonly object ItemDeletingEvent = new object();
103 static readonly object ItemInsertedEvent = new object();
104 static readonly object ItemInsertingEvent = new object();
105 static readonly object ModeChangingEvent = new object();
106 static readonly object ModeChangedEvent = new object();
107 static readonly object ItemUpdatedEvent = new object();
108 static readonly object ItemUpdatingEvent = new object();
112 FormViewMode currentMode = FormViewMode.ReadOnly;
116 public event EventHandler PageIndexChanged {
117 add { Events.AddHandler (PageIndexChangedEvent, value); }
118 remove { Events.RemoveHandler (PageIndexChangedEvent, value); }
121 public event FormViewPageEventHandler PageIndexChanging {
122 add { Events.AddHandler (PageIndexChangingEvent, value); }
123 remove { Events.RemoveHandler (PageIndexChangingEvent, value); }
126 public event FormViewCommandEventHandler ItemCommand {
127 add { Events.AddHandler (ItemCommandEvent, value); }
128 remove { Events.RemoveHandler (ItemCommandEvent, value); }
131 public event EventHandler ItemCreated {
132 add { Events.AddHandler (ItemCreatedEvent, value); }
133 remove { Events.RemoveHandler (ItemCreatedEvent, value); }
136 public event FormViewDeletedEventHandler ItemDeleted {
137 add { Events.AddHandler (ItemDeletedEvent, value); }
138 remove { Events.RemoveHandler (ItemDeletedEvent, value); }
141 public event FormViewDeleteEventHandler ItemDeleting {
142 add { Events.AddHandler (ItemDeletingEvent, value); }
143 remove { Events.RemoveHandler (ItemDeletingEvent, value); }
146 public event FormViewInsertedEventHandler ItemInserted {
147 add { Events.AddHandler (ItemInsertedEvent, value); }
148 remove { Events.RemoveHandler (ItemInsertedEvent, value); }
151 public event FormViewInsertEventHandler ItemInserting {
152 add { Events.AddHandler (ItemInsertingEvent, value); }
153 remove { Events.RemoveHandler (ItemInsertingEvent, value); }
156 public event FormViewModeEventHandler ModeChanging {
157 add { Events.AddHandler (ModeChangingEvent, value); }
158 remove { Events.RemoveHandler (ModeChangingEvent, value); }
161 public event EventHandler ModeChanged {
162 add { Events.AddHandler (ModeChangedEvent, value); }
163 remove { Events.RemoveHandler (ModeChangedEvent, value); }
166 public event FormViewUpdatedEventHandler ItemUpdated {
167 add { Events.AddHandler (ItemUpdatedEvent, value); }
168 remove { Events.RemoveHandler (ItemUpdatedEvent, value); }
171 public event FormViewUpdateEventHandler ItemUpdating {
172 add { Events.AddHandler (ItemUpdatingEvent, value); }
173 remove { Events.RemoveHandler (ItemUpdatingEvent, value); }
176 protected virtual void OnPageIndexChanged (EventArgs e)
178 if (Events != null) {
179 EventHandler eh = (EventHandler) Events [PageIndexChangedEvent];
180 if (eh != null) eh (this, e);
184 protected virtual void OnPageIndexChanging (FormViewPageEventArgs e)
186 if (Events != null) {
187 FormViewPageEventHandler eh = (FormViewPageEventHandler) Events [PageIndexChangingEvent];
193 if (!IsBoundUsingDataSourceID)
194 throw new HttpException (String.Format (unhandledEventExceptionMessage, ID, "PageIndexChanging"));
197 protected virtual void OnItemCommand (FormViewCommandEventArgs e)
199 if (Events != null) {
200 FormViewCommandEventHandler eh = (FormViewCommandEventHandler) Events [ItemCommandEvent];
201 if (eh != null) eh (this, e);
205 protected virtual void OnItemCreated (EventArgs e)
207 if (Events != null) {
208 EventHandler eh = (EventHandler) Events [ItemCreatedEvent];
209 if (eh != null) eh (this, e);
213 protected virtual void OnItemDeleted (FormViewDeletedEventArgs e)
215 if (Events != null) {
216 FormViewDeletedEventHandler eh = (FormViewDeletedEventHandler) Events [ItemDeletedEvent];
217 if (eh != null) eh (this, e);
221 protected virtual void OnItemInserted (FormViewInsertedEventArgs e)
223 if (Events != null) {
224 FormViewInsertedEventHandler eh = (FormViewInsertedEventHandler) Events [ItemInsertedEvent];
225 if (eh != null) eh (this, e);
229 protected virtual void OnItemInserting (FormViewInsertEventArgs e)
231 if (Events != null) {
232 FormViewInsertEventHandler eh = (FormViewInsertEventHandler) Events [ItemInsertingEvent];
238 if (!IsBoundUsingDataSourceID)
239 throw new HttpException (String.Format (unhandledEventExceptionMessage, ID, "ItemInserting"));
242 protected virtual void OnItemDeleting (FormViewDeleteEventArgs e)
244 if (Events != null) {
245 FormViewDeleteEventHandler eh = (FormViewDeleteEventHandler) Events [ItemDeletingEvent];
251 if (!IsBoundUsingDataSourceID)
252 throw new HttpException (String.Format (unhandledEventExceptionMessage, ID, "ItemDeleting"));
255 protected virtual void OnModeChanged (EventArgs e)
257 if (Events != null) {
258 EventHandler eh = (EventHandler) Events [ModeChangedEvent];
259 if (eh != null) eh (this, e);
263 protected virtual void OnModeChanging (FormViewModeEventArgs e)
265 if (Events != null) {
266 FormViewModeEventHandler eh = (FormViewModeEventHandler) Events [ModeChangingEvent];
272 if (!IsBoundUsingDataSourceID)
273 throw new HttpException (String.Format (unhandledEventExceptionMessage, ID, "ModeChanging"));
276 protected virtual void OnItemUpdated (FormViewUpdatedEventArgs e)
278 if (Events != null) {
279 FormViewUpdatedEventHandler eh = (FormViewUpdatedEventHandler) Events [ItemUpdatedEvent];
280 if (eh != null) eh (this, e);
284 protected virtual void OnItemUpdating (FormViewUpdateEventArgs e)
286 if (Events != null) {
287 FormViewUpdateEventHandler eh = (FormViewUpdateEventHandler) Events [ItemUpdatingEvent];
293 if (!IsBoundUsingDataSourceID)
294 throw new HttpException (String.Format (unhandledEventExceptionMessage, ID, "ItemUpdating"));
298 [WebCategoryAttribute ("Paging")]
299 [DefaultValueAttribute (false)]
300 public virtual bool AllowPaging {
302 object ob = ViewState ["AllowPaging"];
308 ViewState ["AllowPaging"] = value;
313 [UrlPropertyAttribute]
314 [WebCategoryAttribute ("Appearance")]
315 [DefaultValueAttribute ("")]
316 [EditorAttribute ("System.Web.UI.Design.ImageUrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
317 public virtual string BackImageUrl {
319 if (ControlStyleCreated)
320 return ((TableStyle) ControlStyle).BackImageUrl;
324 ((TableStyle) ControlStyle).BackImageUrl = value;
328 [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
329 [BrowsableAttribute (false)]
330 public virtual FormViewRow BottomPagerRow {
332 EnsureChildControls ();
333 return bottomPagerRow;
337 [WebCategoryAttribute ("Accessibility")]
338 [DefaultValueAttribute ("")]
339 [LocalizableAttribute (true)]
340 public virtual string Caption {
342 object ob = ViewState ["Caption"];
348 ViewState ["Caption"] = value;
353 [WebCategoryAttribute ("Accessibility")]
354 [DefaultValueAttribute (TableCaptionAlign.NotSet)]
355 public virtual TableCaptionAlign CaptionAlign {
357 object o = ViewState ["CaptionAlign"];
359 return (TableCaptionAlign) o;
360 return TableCaptionAlign.NotSet;
363 ViewState ["CaptionAlign"] = value;
368 [WebCategoryAttribute ("Layout")]
369 [DefaultValueAttribute (-1)]
370 public virtual int CellPadding {
372 if (ControlStyleCreated)
373 return ((TableStyle) ControlStyle).CellPadding;
376 set { ((TableStyle) ControlStyle).CellPadding = value; }
379 [WebCategoryAttribute ("Layout")]
380 [DefaultValueAttribute (0)]
381 public virtual int CellSpacing {
383 if (ControlStyleCreated)
384 return ((TableStyle) ControlStyle).CellSpacing;
388 set { ((TableStyle) ControlStyle).CellSpacing = value; }
391 [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
392 [BrowsableAttribute (false)]
393 public FormViewMode CurrentMode {
394 get { return hasCurrentMode ? currentMode : DefaultMode; }
396 hasCurrentMode = true;
401 FormViewMode defaultMode;
403 [DefaultValueAttribute (FormViewMode.ReadOnly)]
404 [WebCategoryAttribute ("Behavior")]
405 public virtual FormViewMode DefaultMode {
406 get { return defaultMode; }
413 string[] dataKeyNames;
414 [DefaultValueAttribute (null)]
415 [WebCategoryAttribute ("Data")]
416 [TypeConverter (typeof(StringArrayConverter))]
417 [EditorAttribute ("System.Web.UI.Design.WebControls.DataFieldEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
418 public virtual string[] DataKeyNames {
420 if (dataKeyNames == null)
425 dataKeyNames = value;
430 IOrderedDictionary KeyTable {
432 if (_keyTable == null)
433 _keyTable = new OrderedDictionary (DataKeyNames.Length);
438 [BrowsableAttribute (false)]
439 [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
440 public virtual DataKey DataKey {
443 key= new DataKey (KeyTable);
448 DataKey OldEditValues {
450 if (oldEditValues == null)
451 oldEditValues = new DataKey (new OrderedDictionary ());
452 return oldEditValues;
456 [DefaultValue (null)]
457 [TemplateContainer (typeof(FormView), BindingDirection.TwoWay)]
458 [PersistenceMode (PersistenceMode.InnerProperty)]
460 public virtual ITemplate EditItemTemplate {
461 get { return editItemTemplate; }
462 set { editItemTemplate = value; }
465 [WebCategoryAttribute ("Styles")]
466 [PersistenceMode (PersistenceMode.InnerProperty)]
467 [NotifyParentProperty (true)]
468 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
469 [DefaultValueAttribute (null)]
470 public TableItemStyle EditRowStyle {
472 if (editRowStyle == null) {
473 editRowStyle = new TableItemStyle ();
474 if (IsTrackingViewState)
475 editRowStyle.TrackViewState();
481 [WebCategoryAttribute ("Styles")]
482 [PersistenceMode (PersistenceMode.InnerProperty)]
483 [NotifyParentProperty (true)]
484 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
485 [DefaultValueAttribute (null)]
486 public TableItemStyle EmptyDataRowStyle {
488 if (emptyDataRowStyle == null) {
489 emptyDataRowStyle = new TableItemStyle ();
490 if (IsTrackingViewState)
491 emptyDataRowStyle.TrackViewState();
493 return emptyDataRowStyle;
497 [DefaultValue (null)]
498 [TemplateContainer (typeof(FormView), BindingDirection.OneWay)]
499 [PersistenceMode (PersistenceMode.InnerProperty)]
501 public virtual ITemplate EmptyDataTemplate {
502 get { return emptyDataTemplate; }
503 set { emptyDataTemplate = value; }
506 [LocalizableAttribute (true)]
507 [WebCategoryAttribute ("Appearance")]
508 [DefaultValueAttribute ("")]
509 public virtual string EmptyDataText {
511 object ob = ViewState ["EmptyDataText"];
517 ViewState ["EmptyDataText"] = value;
522 [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
523 [BrowsableAttribute (false)]
524 public virtual FormViewRow FooterRow {
526 EnsureChildControls ();
531 [DefaultValue (null)]
532 [TemplateContainer (typeof(FormView), BindingDirection.OneWay)]
533 [PersistenceMode (PersistenceMode.InnerProperty)]
535 public virtual ITemplate FooterTemplate {
536 get { return footerTemplate; }
537 set { footerTemplate = value; }
540 [LocalizableAttribute (true)]
541 [WebCategoryAttribute ("Appearance")]
542 [DefaultValueAttribute ("")]
543 public virtual string FooterText {
545 object ob = ViewState ["FooterText"];
551 ViewState ["FooterText"] = value;
556 [WebCategoryAttribute ("Styles")]
557 [PersistenceMode (PersistenceMode.InnerProperty)]
558 [NotifyParentProperty (true)]
559 [DefaultValue (null)]
560 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
561 public TableItemStyle FooterStyle {
563 if (footerStyle == null) {
564 footerStyle = new TableItemStyle ();
565 if (IsTrackingViewState)
566 footerStyle.TrackViewState();
572 [WebCategoryAttribute ("Appearance")]
573 [DefaultValueAttribute (GridLines.None)]
574 public virtual GridLines GridLines {
576 if (ControlStyleCreated)
577 return ((TableStyle) ControlStyle).GridLines;
578 return GridLines.None;
580 set { ((TableStyle) ControlStyle).GridLines = value; }
583 [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
584 [BrowsableAttribute (false)]
585 public virtual FormViewRow HeaderRow {
587 EnsureChildControls ();
592 [WebCategoryAttribute ("Styles")]
593 [PersistenceMode (PersistenceMode.InnerProperty)]
594 [NotifyParentProperty (true)]
595 [DefaultValue (null)]
596 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
597 public TableItemStyle HeaderStyle {
599 if (headerStyle == null) {
600 headerStyle = new TableItemStyle ();
601 if (IsTrackingViewState)
602 headerStyle.TrackViewState();
608 [DefaultValue (null)]
609 [TemplateContainer (typeof(FormView), BindingDirection.OneWay)]
610 [PersistenceMode (PersistenceMode.InnerProperty)]
612 public virtual ITemplate HeaderTemplate {
613 get { return headerTemplate; }
614 set { headerTemplate = value; }
617 [LocalizableAttribute (true)]
618 [WebCategoryAttribute ("Appearance")]
619 [DefaultValueAttribute ("")]
620 public virtual string HeaderText {
622 object ob = ViewState ["HeaderText"];
628 ViewState ["HeaderText"] = value;
633 [Category ("Layout")]
634 [DefaultValueAttribute (HorizontalAlign.NotSet)]
635 public virtual HorizontalAlign HorizontalAlign {
637 if (ControlStyleCreated)
638 return ((TableStyle) ControlStyle).HorizontalAlign;
639 return HorizontalAlign.NotSet;
641 set { ((TableStyle) ControlStyle).HorizontalAlign = value; }
644 [DefaultValue (null)]
645 [TemplateContainer (typeof(FormView), BindingDirection.TwoWay)]
646 [PersistenceMode (PersistenceMode.InnerProperty)]
648 public virtual ITemplate InsertItemTemplate {
649 get { return insertItemTemplate; }
650 set { insertItemTemplate = value; }
653 [WebCategoryAttribute ("Styles")]
654 [PersistenceMode (PersistenceMode.InnerProperty)]
655 [NotifyParentProperty (true)]
656 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
657 [DefaultValueAttribute (null)]
658 public TableItemStyle InsertRowStyle {
660 if (insertRowStyle == null) {
661 insertRowStyle = new TableItemStyle ();
662 if (IsTrackingViewState)
663 insertRowStyle.TrackViewState();
665 return insertRowStyle;
669 [DefaultValue (null)]
670 [TemplateContainer (typeof(FormView), BindingDirection.TwoWay)]
671 [PersistenceMode (PersistenceMode.InnerProperty)]
673 public virtual ITemplate ItemTemplate {
674 get { return itemTemplate; }
675 set { itemTemplate = value; }
678 [BrowsableAttribute (false)]
679 [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
680 public virtual int PageCount {
681 get { return pageCount; }
682 private set { pageCount = value; }
685 [WebCategoryAttribute ("Paging")]
686 [BindableAttribute (true, BindingDirection.OneWay)]
687 [DefaultValueAttribute (0)]
688 public virtual int PageIndex {
689 get { return pageIndex; }
692 throw new ArgumentOutOfRangeException ("PageIndex must be non-negative");
693 if (pageIndex == value || value == -1)
700 [WebCategoryAttribute ("Paging")]
701 [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Content)]
702 [NotifyParentPropertyAttribute (true)]
703 [PersistenceModeAttribute (PersistenceMode.InnerProperty)]
704 public virtual PagerSettings PagerSettings {
706 if (pagerSettings == null) {
707 pagerSettings = new PagerSettings (this);
708 if (IsTrackingViewState)
709 ((IStateManager)pagerSettings).TrackViewState ();
711 return pagerSettings;
715 [WebCategoryAttribute ("Styles")]
716 [PersistenceMode (PersistenceMode.InnerProperty)]
717 [NotifyParentProperty (true)]
718 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
719 public TableItemStyle PagerStyle {
721 if (pagerStyle == null) {
722 pagerStyle = new TableItemStyle ();
723 if (IsTrackingViewState)
724 pagerStyle.TrackViewState();
731 [DefaultValue (null)]
732 [TemplateContainerAttribute (typeof (FormView))]
733 [PersistenceMode (PersistenceMode.InnerProperty)]
735 public virtual ITemplate PagerTemplate {
736 get { return pagerTemplate; }
737 set { pagerTemplate = value; }
740 [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
741 [BrowsableAttribute (false)]
742 public virtual FormViewRow Row {
744 EnsureChildControls ();
749 [WebCategoryAttribute ("Styles")]
750 [PersistenceMode (PersistenceMode.InnerProperty)]
751 [NotifyParentProperty (true)]
752 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
753 [DefaultValue (null)]
754 public TableItemStyle RowStyle {
756 if (rowStyle == null) {
757 rowStyle = new TableItemStyle ();
758 if (IsTrackingViewState)
759 rowStyle.TrackViewState();
765 [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
766 [BrowsableAttribute (false)]
767 public object SelectedValue {
768 get { return DataKey.Value; }
771 [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
772 [BrowsableAttribute (false)]
773 public virtual FormViewRow TopPagerRow {
775 EnsureChildControls ();
780 [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
781 [BrowsableAttribute (false)]
782 public virtual object DataItem {
783 get { return dataItem; }
786 [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
787 [BrowsableAttribute (false)]
788 public int DataItemCount {
789 get { return PageCount; }
792 [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
793 [BrowsableAttribute (false)]
794 public virtual int DataItemIndex {
795 get { return PageIndex; }
798 int IDataItemContainer.DataItemIndex {
799 get { return DataItemIndex; }
802 int IDataItemContainer.DisplayIndex {
803 get { return PageIndex; }
806 [MonoTODO ("Make use of it in the code")]
807 [DefaultValue (true)]
808 public virtual bool EnableModelValidation {
813 [DefaultValue (true)]
814 public virtual bool RenderOuterTable {
815 get { return renderOuterTable; }
816 set { renderOuterTable = value; }
819 DataBoundControlMode IDataBoundItemControl.Mode {
821 switch (CurrentMode) {
822 case FormViewMode.ReadOnly:
823 return DataBoundControlMode.ReadOnly;
825 case FormViewMode.Edit:
826 return DataBoundControlMode.Edit;
828 case FormViewMode.Insert:
829 return DataBoundControlMode.Insert;
832 throw new InvalidOperationException ("Unsupported mode value.");
837 protected internal virtual string ModifiedOuterTableStylePropertyName ()
839 if (BackImageUrl != String.Empty)
840 return "BackImageUrl";
842 if (CellPadding != -1)
843 return "CellPadding";
845 if (CellSpacing != 0)
846 return "CellSpacing";
848 if (GridLines != GridLines.None)
851 if (HorizontalAlign != HorizontalAlign.NotSet)
852 return "HorizontalAlign";
854 if (ControlStyle.CheckBit ((int)global::System.Web.UI.WebControls.Style.Styles.FontAll))
860 internal override string InlinePropertiesSet ()
862 string baseProps = base.InlinePropertiesSet ();
863 string props = ModifiedOuterTableStylePropertyName ();
864 if (String.IsNullOrEmpty (props))
867 if (String.IsNullOrEmpty (baseProps))
870 return baseProps + ", " + props;
873 public virtual bool IsBindableType (Type type)
875 return type.IsPrimitive || type == typeof (string) || type == typeof (DateTime) || type == typeof (Guid) || type == typeof (Decimal);
878 protected override DataSourceSelectArguments CreateDataSourceSelectArguments ()
880 DataSourceSelectArguments arg = new DataSourceSelectArguments ();
881 DataSourceView view = GetData ();
882 if (AllowPaging && view.CanPage) {
883 arg.StartRowIndex = PageIndex;
884 if (view.CanRetrieveTotalRowCount) {
885 arg.RetrieveTotalRowCount = true;
888 arg.MaximumRows = -1;
893 protected virtual FormViewRow CreateRow (int rowIndex, DataControlRowType rowType, DataControlRowState rowState)
895 if (rowType == DataControlRowType.Pager)
896 return new FormViewPagerRow (rowIndex, rowType, rowState);
898 return new FormViewRow (rowIndex, rowType, rowState);
901 void RequireBinding ()
904 RequiresDataBinding = true;
907 protected virtual Table CreateTable ()
909 return new ContainedTable (this);
912 protected override void EnsureDataBound ()
914 if (CurrentMode == FormViewMode.Insert) {
915 if (RequiresDataBinding) {
916 OnDataBinding (EventArgs.Empty);
917 RequiresDataBinding = false;
918 InternalPerformDataBinding (null);
920 OnDataBound (EventArgs.Empty);
923 base.EnsureDataBound ();
926 protected override Style CreateControlStyle ()
928 TableStyle style = new TableStyle (ViewState);
929 style.CellSpacing = 0;
933 protected override int CreateChildControls (IEnumerable data, bool dataBinding)
935 PagedDataSource dataSource = new PagedDataSource ();
936 dataSource.DataSource = CurrentMode != FormViewMode.Insert ? data : null;
937 dataSource.AllowPaging = AllowPaging;
938 dataSource.PageSize = 1;
939 dataSource.CurrentPageIndex = PageIndex;
941 if (dataBinding && CurrentMode != FormViewMode.Insert) {
942 DataSourceView view = GetData ();
943 if (view != null && view.CanPage) {
944 dataSource.AllowServerPaging = true;
945 if (SelectArguments.RetrieveTotalRowCount)
946 dataSource.VirtualCount = SelectArguments.TotalRowCount;
950 PagerSettings pagerSettings = PagerSettings;
951 bool showPager = AllowPaging && pagerSettings.Visible && (dataSource.PageCount > 1);
954 table = CreateTable ();
955 Controls.Add (table);
959 bottomPagerRow = null;
961 // Gets the current data item
964 PageCount = dataSource.DataSourceCount;
965 if (PageIndex >= PageCount && PageCount > 0)
966 pageIndex = dataSource.CurrentPageIndex = PageCount - 1;
968 if (dataSource.DataSource != null) {
969 IEnumerator e = dataSource.GetEnumerator ();
971 dataItem = e.Current;
975 object lastItem = null;
976 if (dataSource.DataSource != null) {
977 IEnumerator e = dataSource.GetEnumerator ();
978 for (; e.MoveNext (); page++) {
979 lastItem = e.Current;
980 if (page == PageIndex)
981 dataItem = e.Current;
985 if (PageIndex >= PageCount && PageCount > 0) {
986 pageIndex = PageCount - 1;
991 // Main table creation
992 bool emptyRow = PageCount == 0 && CurrentMode != FormViewMode.Insert;
995 headerRow = CreateRow (-1, DataControlRowType.Header, DataControlRowState.Normal);
996 InitializeRow (headerRow);
997 table.Rows.Add (headerRow);
1000 if (showPager && pagerSettings.Position == PagerPosition.Top || pagerSettings.Position == PagerPosition.TopAndBottom) {
1001 topPagerRow = CreateRow (-1, DataControlRowType.Pager, DataControlRowState.Normal);
1002 InitializePager (topPagerRow, dataSource);
1003 table.Rows.Add (topPagerRow);
1006 if (PageCount > 0) {
1007 DataControlRowState rstate = GetRowState ();
1008 itemRow = CreateRow (0, DataControlRowType.DataRow, rstate);
1009 InitializeRow (itemRow);
1010 table.Rows.Add (itemRow);
1012 switch (CurrentMode) {
1013 case FormViewMode.Edit:
1014 itemRow = CreateRow (-1, DataControlRowType.EmptyDataRow, DataControlRowState.Edit);
1016 case FormViewMode.Insert:
1017 itemRow = CreateRow (-1, DataControlRowType.DataRow, DataControlRowState.Insert);
1020 itemRow = CreateRow (-1, DataControlRowType.EmptyDataRow, DataControlRowState.Normal);
1023 InitializeRow (itemRow);
1024 table.Rows.Add (itemRow);
1028 footerRow = CreateRow (-1, DataControlRowType.Footer, DataControlRowState.Normal);
1029 InitializeRow (footerRow);
1030 table.Rows.Add (footerRow);
1033 if (showPager && pagerSettings.Position == PagerPosition.Bottom || pagerSettings.Position == PagerPosition.TopAndBottom) {
1034 bottomPagerRow = CreateRow (0, DataControlRowType.Pager, DataControlRowState.Normal);
1035 InitializePager (bottomPagerRow, dataSource);
1036 table.Rows.Add (bottomPagerRow);
1039 OnItemCreated (EventArgs.Empty);
1047 DataControlRowState GetRowState ()
1049 DataControlRowState rstate = DataControlRowState.Normal;
1050 if (CurrentMode == FormViewMode.Edit)
1051 rstate |= DataControlRowState.Edit;
1052 else if (CurrentMode == FormViewMode.Insert)
1053 rstate |= DataControlRowState.Insert;
1057 protected virtual void InitializePager (FormViewRow row, PagedDataSource dataSource)
1059 TableCell cell = new TableCell ();
1060 cell.ColumnSpan = 2;
1062 if (pagerTemplate != null)
1063 pagerTemplate.InstantiateIn (cell);
1065 cell.Controls.Add (PagerSettings.CreatePagerControl (dataSource.CurrentPageIndex, dataSource.PageCount));
1067 row.Cells.Add (cell);
1070 protected virtual void InitializeRow (FormViewRow row)
1072 TableCell cell = new TableCell ();
1073 if (row.RowType == DataControlRowType.DataRow) {
1074 if ((row.RowState & DataControlRowState.Edit) != 0) {
1075 if (editItemTemplate != null)
1076 editItemTemplate.InstantiateIn (cell);
1078 row.Visible = false;
1079 } else if ((row.RowState & DataControlRowState.Insert) != 0) {
1080 if (insertItemTemplate != null)
1081 insertItemTemplate.InstantiateIn (cell);
1083 row.Visible = false;
1084 } else if (itemTemplate != null)
1085 itemTemplate.InstantiateIn (cell);
1087 row.Visible = false;
1088 } else if (row.RowType == DataControlRowType.EmptyDataRow) {
1089 if (emptyDataTemplate != null)
1090 emptyDataTemplate.InstantiateIn (cell);
1091 else if (!String.IsNullOrEmpty (EmptyDataText))
1092 cell.Text = EmptyDataText;
1094 row.Visible = false;
1095 } else if (row.RowType == DataControlRowType.Footer)
1097 if (footerTemplate != null)
1098 footerTemplate.InstantiateIn (cell);
1099 else if (!String.IsNullOrEmpty (FooterText))
1100 cell.Text = FooterText;
1102 row.Visible = false;
1103 } else if (row.RowType == DataControlRowType.Header)
1105 if (headerTemplate != null)
1106 headerTemplate.InstantiateIn (cell);
1107 else if (!String.IsNullOrEmpty (HeaderText))
1108 cell.Text = HeaderText;
1110 row.Visible = false;
1112 cell.ColumnSpan = 2;
1113 row.Cells.Add (cell);
1115 row.RenderJustCellContents = !RenderOuterTable;
1119 void FillRowDataKey (object dataItem)
1123 if (cachedKeyProperties == null) {
1124 PropertyDescriptorCollection props = TypeDescriptor.GetProperties (dataItem);
1125 cachedKeyProperties = new PropertyDescriptor [DataKeyNames.Length];
1126 for (int n=0; n<DataKeyNames.Length; n++) {
1127 PropertyDescriptor p = props.Find (DataKeyNames [n], true);
1129 throw new InvalidOperationException ("Property '" + DataKeyNames[n] + "' not found in object of type " + dataItem.GetType());
1130 cachedKeyProperties [n] = p;
1133 foreach (PropertyDescriptor p in cachedKeyProperties)
1134 KeyTable [p.Name] = p.GetValue (dataItem);
1137 IOrderedDictionary GetRowValues (bool includePrimaryKey)
1139 OrderedDictionary dic = new OrderedDictionary ();
1140 ExtractRowValues (dic, includePrimaryKey);
1144 protected virtual void ExtractRowValues (IOrderedDictionary fieldValues, bool includeKeys)
1146 FormViewRow row = Row;
1150 DataControlRowState rowState = row.RowState;
1151 IBindableTemplate bt;
1153 if ((rowState & DataControlRowState.Insert) != 0)
1154 bt = insertItemTemplate as IBindableTemplate;
1155 else if ((rowState & DataControlRowState.Edit) != 0)
1156 bt = editItemTemplate as IBindableTemplate;
1161 IOrderedDictionary values = bt.ExtractValues (row.Cells [0]);
1162 if (values != null) {
1163 foreach (DictionaryEntry e in values) {
1164 if (includeKeys || Array.IndexOf (DataKeyNames, e.Key) == -1)
1165 fieldValues [e.Key] = e.Value;
1171 protected override HtmlTextWriterTag TagKey {
1172 get { return HtmlTextWriterTag.Table; }
1175 public sealed override void DataBind ()
1177 cachedKeyProperties = null;
1180 if (pageCount > 0) {
1181 if (CurrentMode == FormViewMode.Edit)
1182 oldEditValues = new DataKey (GetRowValues (true));
1183 FillRowDataKey (dataItem);
1184 key = new DataKey (KeyTable);
1188 protected internal override void PerformDataBinding (IEnumerable data)
1190 base.PerformDataBinding (data);
1193 protected internal virtual void PrepareControlHierarchy ()
1198 table.Caption = Caption;
1199 table.CaptionAlign = CaptionAlign;
1201 foreach (FormViewRow row in table.Rows) {
1202 switch (row.RowType) {
1203 case DataControlRowType.Header:
1204 if (headerStyle != null && !headerStyle.IsEmpty)
1205 row.ControlStyle.CopyFrom (headerStyle);
1207 case DataControlRowType.Footer:
1208 if (footerStyle != null && !footerStyle.IsEmpty)
1209 row.ControlStyle.CopyFrom (footerStyle);
1211 case DataControlRowType.Pager:
1212 if (pagerStyle != null && !pagerStyle.IsEmpty)
1213 row.ControlStyle.CopyFrom (pagerStyle);
1215 case DataControlRowType.EmptyDataRow:
1216 if (emptyDataRowStyle != null && !emptyDataRowStyle.IsEmpty)
1217 row.ControlStyle.CopyFrom (emptyDataRowStyle);
1219 case DataControlRowType.DataRow:
1220 if (rowStyle != null && !rowStyle.IsEmpty)
1221 row.ControlStyle.CopyFrom (rowStyle);
1222 if ((row.RowState & (DataControlRowState.Edit | DataControlRowState.Insert)) != 0 && editRowStyle != null && !editRowStyle.IsEmpty)
1223 row.ControlStyle.CopyFrom (editRowStyle);
1224 if ((row.RowState & DataControlRowState.Insert) != 0 && insertRowStyle != null && !insertRowStyle.IsEmpty)
1225 row.ControlStyle.CopyFrom (insertRowStyle);
1233 protected internal override void OnInit (EventArgs e)
1235 Page.RegisterRequiresControlState (this);
1239 protected override bool OnBubbleEvent (object source, EventArgs e)
1241 FormViewCommandEventArgs args = e as FormViewCommandEventArgs;
1243 bool causesValidation = false;
1244 IButtonControl button = args.CommandSource as IButtonControl;
1245 if (button != null && button.CausesValidation) {
1246 Page.Validate (button.ValidationGroup);
1247 causesValidation = true;
1249 ProcessCommand (args, causesValidation);
1252 return base.OnBubbleEvent (source, e);
1255 void ProcessCommand (FormViewCommandEventArgs args, bool causesValidation)
1257 OnItemCommand (args);
1258 ProcessEvent (args.CommandName, args.CommandArgument as string, causesValidation);
1261 void IPostBackEventHandler.RaisePostBackEvent (string eventArgument)
1263 RaisePostBackEvent (eventArgument);
1266 protected virtual void RaisePostBackEvent (string eventArgument)
1268 int i = eventArgument.IndexOf ('$');
1269 CommandEventArgs arg;
1271 arg = new CommandEventArgs (eventArgument.Substring (0, i), eventArgument.Substring (i + 1));
1273 arg = new CommandEventArgs (eventArgument, null);
1274 ProcessCommand (new FormViewCommandEventArgs (this, arg), false);
1277 void ProcessEvent (string eventName, string param, bool causesValidation)
1279 switch (eventName) {
1280 case DataControlCommands.PageCommandName:
1283 case DataControlCommands.FirstPageCommandArgument:
1286 case DataControlCommands.LastPageCommandArgument:
1287 newIndex = PageCount - 1;
1289 case DataControlCommands.NextPageCommandArgument:
1290 newIndex = PageIndex + 1;
1292 case DataControlCommands.PreviousPageCommandArgument:
1293 newIndex = PageIndex - 1;
1297 int.TryParse (param, out paramIndex);
1298 newIndex = paramIndex - 1;
1301 SetPageIndex (newIndex);
1304 case DataControlCommands.FirstPageCommandArgument:
1308 case DataControlCommands.LastPageCommandArgument:
1309 SetPageIndex (PageCount - 1);
1312 case DataControlCommands.NextPageCommandArgument:
1313 if (PageIndex < PageCount - 1)
1314 SetPageIndex (PageIndex + 1);
1317 case DataControlCommands.PreviousPageCommandArgument:
1319 SetPageIndex (PageIndex - 1);
1322 case DataControlCommands.EditCommandName:
1323 ProcessChangeMode (FormViewMode.Edit, false);
1326 case DataControlCommands.NewCommandName:
1327 ProcessChangeMode (FormViewMode.Insert, false);
1330 case DataControlCommands.UpdateCommandName:
1331 UpdateItem (param, causesValidation);
1334 case DataControlCommands.CancelCommandName:
1338 case DataControlCommands.DeleteCommandName:
1342 case DataControlCommands.InsertCommandName:
1343 InsertItem (causesValidation);
1350 void SetPageIndex (int index)
1352 FormViewPageEventArgs args = new FormViewPageEventArgs (index);
1353 OnPageIndexChanging (args);
1355 if (args.Cancel || !IsBoundUsingDataSourceID)
1358 int newIndex = args.NewPageIndex;
1359 if (newIndex < 0 || newIndex >= PageCount)
1361 EndRowEdit (false, false);
1362 PageIndex = newIndex;
1363 OnPageIndexChanged (EventArgs.Empty);
1366 public void ChangeMode (FormViewMode newMode)
1368 if (CurrentMode == newMode)
1370 CurrentMode = newMode;
1374 void ProcessChangeMode (FormViewMode newMode, bool cancelingEdit)
1376 FormViewModeEventArgs args = new FormViewModeEventArgs (newMode, cancelingEdit);
1377 OnModeChanging (args);
1379 if (args.Cancel || !IsBoundUsingDataSourceID)
1382 ChangeMode (args.NewMode);
1384 OnModeChanged (EventArgs.Empty);
1389 EndRowEdit (true, true);
1392 public virtual void UpdateItem (bool causesValidation)
1394 UpdateItem (null, causesValidation);
1397 void UpdateItem (string param, bool causesValidation)
1399 if (causesValidation && Page != null && !Page.IsValid)
1402 if (currentMode != FormViewMode.Edit)
1403 throw new HttpException ("Must be in Edit mode");
1405 currentEditOldValues = OldEditValues.Values;
1406 currentEditRowKeys = DataKey.Values;
1407 currentEditNewValues = GetRowValues (true);
1409 FormViewUpdateEventArgs args = new FormViewUpdateEventArgs (param, currentEditRowKeys, currentEditOldValues, currentEditNewValues);
1410 OnItemUpdating (args);
1412 if (args.Cancel || !IsBoundUsingDataSourceID)
1415 DataSourceView view = GetData ();
1417 throw new HttpException ("The DataSourceView associated to data bound control was null");
1418 view.Update (currentEditRowKeys, currentEditNewValues, currentEditOldValues, new DataSourceViewOperationCallback (UpdateCallback));
1421 bool UpdateCallback (int recordsAffected, Exception exception)
1423 FormViewUpdatedEventArgs dargs = new FormViewUpdatedEventArgs (recordsAffected, exception, currentEditRowKeys, currentEditOldValues, currentEditNewValues);
1424 OnItemUpdated (dargs);
1426 if (!dargs.KeepInEditMode)
1427 EndRowEdit (true, false);
1429 return dargs.ExceptionHandled;
1432 public virtual void InsertItem (bool causesValidation)
1434 InsertItem (null, causesValidation);
1437 void InsertItem (string param, bool causesValidation)
1439 if (causesValidation && Page != null && !Page.IsValid)
1442 if (currentMode != FormViewMode.Insert)
1443 throw new HttpException ("Must be in Insert mode");
1445 currentEditNewValues = GetRowValues (true);
1446 FormViewInsertEventArgs args = new FormViewInsertEventArgs (param, currentEditNewValues);
1447 OnItemInserting (args);
1449 if (args.Cancel || !IsBoundUsingDataSourceID)
1452 DataSourceView view = GetData ();
1454 throw new HttpException ("The DataSourceView associated to data bound control was null");
1455 view.Insert (currentEditNewValues, new DataSourceViewOperationCallback (InsertCallback));
1458 bool InsertCallback (int recordsAffected, Exception exception)
1460 FormViewInsertedEventArgs dargs = new FormViewInsertedEventArgs (recordsAffected, exception, currentEditNewValues);
1461 OnItemInserted (dargs);
1463 if (!dargs.KeepInInsertMode)
1464 EndRowEdit (true, false);
1466 return dargs.ExceptionHandled;
1469 public virtual void DeleteItem ()
1471 currentEditRowKeys = DataKey.Values;
1472 currentEditNewValues = GetRowValues (true);
1474 FormViewDeleteEventArgs args = new FormViewDeleteEventArgs (PageIndex, currentEditRowKeys, currentEditNewValues);
1475 OnItemDeleting (args);
1477 if (args.Cancel || !IsBoundUsingDataSourceID)
1480 if (PageIndex > 0 && PageIndex == PageCount - 1)
1485 DataSourceView view = GetData ();
1487 view.Delete (currentEditRowKeys, currentEditNewValues, new DataSourceViewOperationCallback (DeleteCallback));
1489 FormViewDeletedEventArgs dargs = new FormViewDeletedEventArgs (0, null, currentEditRowKeys, currentEditNewValues);
1490 OnItemDeleted (dargs);
1494 bool DeleteCallback (int recordsAffected, Exception exception)
1496 FormViewDeletedEventArgs dargs = new FormViewDeletedEventArgs (recordsAffected, exception, currentEditRowKeys, currentEditNewValues);
1497 OnItemDeleted (dargs);
1498 return dargs.ExceptionHandled;
1501 void EndRowEdit (bool switchToDefaultMode, bool cancelingEdit)
1503 if (switchToDefaultMode)
1504 ProcessChangeMode (DefaultMode, cancelingEdit);
1505 oldEditValues = new DataKey (new OrderedDictionary ());
1506 currentEditRowKeys = null;
1507 currentEditOldValues = null;
1508 currentEditNewValues = null;
1512 protected internal override void LoadControlState (object ob)
1514 if (ob == null) return;
1515 object[] state = (object[]) ob;
1516 base.LoadControlState (state[0]);
1517 pageIndex = (int) state[1];
1518 pageCount = (int) state[2];
1519 CurrentMode = (FormViewMode) state[3];
1520 defaultMode = (FormViewMode) state[4];
1521 dataKeyNames = (string[]) state[5];
1522 if (state [6] != null)
1523 ((IStateManager) DataKey).LoadViewState (state [6]);
1524 if (state [7] != null)
1525 ((IStateManager) OldEditValues).LoadViewState (state [7]);
1528 protected internal override object SaveControlState ()
1530 object bstate = base.SaveControlState ();
1531 return new object [] {
1538 (key == null ? null : ((IStateManager)key).SaveViewState()),
1539 (oldEditValues == null ? null : ((IStateManager) oldEditValues).SaveViewState ())
1543 protected override void TrackViewState()
1545 base.TrackViewState();
1546 if (pagerSettings != null)
1547 ((IStateManager)pagerSettings).TrackViewState();
1548 if (footerStyle != null)
1549 ((IStateManager)footerStyle).TrackViewState();
1550 if (headerStyle != null)
1551 ((IStateManager)headerStyle).TrackViewState();
1552 if (pagerStyle != null)
1553 ((IStateManager)pagerStyle).TrackViewState();
1554 if (rowStyle != null)
1555 ((IStateManager)rowStyle).TrackViewState();
1556 if (editRowStyle != null)
1557 ((IStateManager)editRowStyle).TrackViewState();
1558 if (insertRowStyle != null)
1559 ((IStateManager)insertRowStyle).TrackViewState();
1560 if (emptyDataRowStyle != null)
1561 ((IStateManager)emptyDataRowStyle).TrackViewState();
1564 protected override object SaveViewState()
1566 object[] states = new object [10];
1567 states[0] = base.SaveViewState();
1568 states[1] = (pagerSettings == null ? null : ((IStateManager)pagerSettings).SaveViewState());
1569 states[2] = (footerStyle == null ? null : ((IStateManager)footerStyle).SaveViewState());
1570 states[3] = (headerStyle == null ? null : ((IStateManager)headerStyle).SaveViewState());
1571 states[4] = (pagerStyle == null ? null : ((IStateManager)pagerStyle).SaveViewState());
1572 states[5] = (rowStyle == null ? null : ((IStateManager)rowStyle).SaveViewState());
1573 states[6] = (insertRowStyle == null ? null : ((IStateManager)insertRowStyle).SaveViewState());
1574 states[7] = (editRowStyle == null ? null : ((IStateManager)editRowStyle).SaveViewState());
1575 states[8] = (emptyDataRowStyle == null ? null : ((IStateManager)emptyDataRowStyle).SaveViewState());
1577 for (int i = states.Length - 1; i >= 0; i--) {
1578 if (states [i] != null)
1585 protected override void LoadViewState (object savedState)
1587 if (savedState == null) {
1588 base.LoadViewState (null);
1592 object [] states = (object []) savedState;
1594 base.LoadViewState (states[0]);
1596 if (states[1] != null)
1597 ((IStateManager)PagerSettings).LoadViewState (states[1]);
1598 if (states[2] != null)
1599 ((IStateManager)FooterStyle).LoadViewState (states[2]);
1600 if (states[3] != null)
1601 ((IStateManager)HeaderStyle).LoadViewState (states[3]);
1602 if (states[4] != null)
1603 ((IStateManager)PagerStyle).LoadViewState (states[4]);
1604 if (states[5] != null)
1605 ((IStateManager)RowStyle).LoadViewState (states[5]);
1606 if (states[6] != null)
1607 ((IStateManager)InsertRowStyle).LoadViewState (states[6]);
1608 if (states[7] != null)
1609 ((IStateManager)EditRowStyle).LoadViewState (states[7]);
1610 if (states[8] != null)
1611 ((IStateManager)EmptyDataRowStyle).LoadViewState (states[8]);
1614 protected internal override void Render (HtmlTextWriter writer)
1617 VerifyInlinePropertiesNotSet ();
1618 if (RenderOuterTable) {
1620 PrepareControlHierarchy ();
1622 table.Render (writer);
1624 } else if (table != null)
1625 table.RenderChildren (writer);
1629 PostBackOptions IPostBackContainer.GetPostBackOptions (IButtonControl control)
1631 if (control == null)
1632 throw new ArgumentNullException ("control");
1634 if (control.CausesValidation)
1635 throw new InvalidOperationException ("A button that causes validation in FormView '" + ID + "' is attempting to use the container GridView as the post back target. The button should either turn off validation or use itself as the post back container.");
1637 PostBackOptions options = new PostBackOptions (this);
1638 options.Argument = control.CommandName + "$" + control.CommandArgument;
1639 options.RequiresJavaScriptProtocol = true;