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")]
45 [DataKeyProperty ("DataKey")]
46 [AspNetHostingPermissionAttribute (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
47 [AspNetHostingPermissionAttribute (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
48 public class FormView: CompositeDataBoundControl, IDataItemContainer, INamingContainer, IPostBackEventHandler, IPostBackContainer
49 , IDataBoundItemControl, IDataBoundControl, IRenderOuterTable
54 FormViewRow headerRow;
55 FormViewRow footerRow;
56 FormViewRow bottomPagerRow;
57 FormViewRow topPagerRow;
60 IOrderedDictionary currentEditRowKeys;
61 IOrderedDictionary currentEditNewValues;
62 IOrderedDictionary currentEditOldValues;
64 ITemplate pagerTemplate;
65 ITemplate emptyDataTemplate;
66 ITemplate headerTemplate;
67 ITemplate footerTemplate;
68 ITemplate editItemTemplate;
69 ITemplate insertItemTemplate;
70 ITemplate itemTemplate;
72 PropertyDescriptor[] cachedKeyProperties;
73 readonly string[] emptyKeys = new string[0];
74 readonly string unhandledEventExceptionMessage = "The FormView '{0}' fired event {1} which wasn't handled.";
77 PagerSettings pagerSettings;
79 TableItemStyle editRowStyle;
80 TableItemStyle insertRowStyle;
81 TableItemStyle emptyDataRowStyle;
82 TableItemStyle footerStyle;
83 TableItemStyle headerStyle;
84 TableItemStyle pagerStyle;
85 TableItemStyle rowStyle;
87 IOrderedDictionary _keyTable;
89 DataKey oldEditValues;
90 bool renderOuterTable = true;
91 static readonly object PageIndexChangedEvent = new object();
92 static readonly object PageIndexChangingEvent = new object();
93 static readonly object ItemCommandEvent = new object();
94 static readonly object ItemCreatedEvent = new object();
95 static readonly object ItemDeletedEvent = new object();
96 static readonly object ItemDeletingEvent = new object();
97 static readonly object ItemInsertedEvent = new object();
98 static readonly object ItemInsertingEvent = new object();
99 static readonly object ModeChangingEvent = new object();
100 static readonly object ModeChangedEvent = new object();
101 static readonly object ItemUpdatedEvent = new object();
102 static readonly object ItemUpdatingEvent = new object();
106 FormViewMode currentMode = FormViewMode.ReadOnly;
110 public event EventHandler PageIndexChanged {
111 add { Events.AddHandler (PageIndexChangedEvent, value); }
112 remove { Events.RemoveHandler (PageIndexChangedEvent, value); }
115 public event FormViewPageEventHandler PageIndexChanging {
116 add { Events.AddHandler (PageIndexChangingEvent, value); }
117 remove { Events.RemoveHandler (PageIndexChangingEvent, value); }
120 public event FormViewCommandEventHandler ItemCommand {
121 add { Events.AddHandler (ItemCommandEvent, value); }
122 remove { Events.RemoveHandler (ItemCommandEvent, value); }
125 public event EventHandler ItemCreated {
126 add { Events.AddHandler (ItemCreatedEvent, value); }
127 remove { Events.RemoveHandler (ItemCreatedEvent, value); }
130 public event FormViewDeletedEventHandler ItemDeleted {
131 add { Events.AddHandler (ItemDeletedEvent, value); }
132 remove { Events.RemoveHandler (ItemDeletedEvent, value); }
135 public event FormViewDeleteEventHandler ItemDeleting {
136 add { Events.AddHandler (ItemDeletingEvent, value); }
137 remove { Events.RemoveHandler (ItemDeletingEvent, value); }
140 public event FormViewInsertedEventHandler ItemInserted {
141 add { Events.AddHandler (ItemInsertedEvent, value); }
142 remove { Events.RemoveHandler (ItemInsertedEvent, value); }
145 public event FormViewInsertEventHandler ItemInserting {
146 add { Events.AddHandler (ItemInsertingEvent, value); }
147 remove { Events.RemoveHandler (ItemInsertingEvent, value); }
150 public event FormViewModeEventHandler ModeChanging {
151 add { Events.AddHandler (ModeChangingEvent, value); }
152 remove { Events.RemoveHandler (ModeChangingEvent, value); }
155 public event EventHandler ModeChanged {
156 add { Events.AddHandler (ModeChangedEvent, value); }
157 remove { Events.RemoveHandler (ModeChangedEvent, value); }
160 public event FormViewUpdatedEventHandler ItemUpdated {
161 add { Events.AddHandler (ItemUpdatedEvent, value); }
162 remove { Events.RemoveHandler (ItemUpdatedEvent, value); }
165 public event FormViewUpdateEventHandler ItemUpdating {
166 add { Events.AddHandler (ItemUpdatingEvent, value); }
167 remove { Events.RemoveHandler (ItemUpdatingEvent, value); }
170 protected virtual void OnPageIndexChanged (EventArgs e)
172 if (Events != null) {
173 EventHandler eh = (EventHandler) Events [PageIndexChangedEvent];
174 if (eh != null) eh (this, e);
178 protected virtual void OnPageIndexChanging (FormViewPageEventArgs e)
180 if (Events != null) {
181 FormViewPageEventHandler eh = (FormViewPageEventHandler) Events [PageIndexChangingEvent];
187 if (!IsBoundUsingDataSourceID)
188 throw new HttpException (String.Format (unhandledEventExceptionMessage, ID, "PageIndexChanging"));
191 protected virtual void OnItemCommand (FormViewCommandEventArgs e)
193 if (Events != null) {
194 FormViewCommandEventHandler eh = (FormViewCommandEventHandler) Events [ItemCommandEvent];
195 if (eh != null) eh (this, e);
199 protected virtual void OnItemCreated (EventArgs e)
201 if (Events != null) {
202 EventHandler eh = (EventHandler) Events [ItemCreatedEvent];
203 if (eh != null) eh (this, e);
207 protected virtual void OnItemDeleted (FormViewDeletedEventArgs e)
209 if (Events != null) {
210 FormViewDeletedEventHandler eh = (FormViewDeletedEventHandler) Events [ItemDeletedEvent];
211 if (eh != null) eh (this, e);
215 protected virtual void OnItemInserted (FormViewInsertedEventArgs e)
217 if (Events != null) {
218 FormViewInsertedEventHandler eh = (FormViewInsertedEventHandler) Events [ItemInsertedEvent];
219 if (eh != null) eh (this, e);
223 protected virtual void OnItemInserting (FormViewInsertEventArgs e)
225 if (Events != null) {
226 FormViewInsertEventHandler eh = (FormViewInsertEventHandler) Events [ItemInsertingEvent];
232 if (!IsBoundUsingDataSourceID)
233 throw new HttpException (String.Format (unhandledEventExceptionMessage, ID, "ItemInserting"));
236 protected virtual void OnItemDeleting (FormViewDeleteEventArgs e)
238 if (Events != null) {
239 FormViewDeleteEventHandler eh = (FormViewDeleteEventHandler) Events [ItemDeletingEvent];
245 if (!IsBoundUsingDataSourceID)
246 throw new HttpException (String.Format (unhandledEventExceptionMessage, ID, "ItemDeleting"));
249 protected virtual void OnModeChanged (EventArgs e)
251 if (Events != null) {
252 EventHandler eh = (EventHandler) Events [ModeChangedEvent];
253 if (eh != null) eh (this, e);
257 protected virtual void OnModeChanging (FormViewModeEventArgs e)
259 if (Events != null) {
260 FormViewModeEventHandler eh = (FormViewModeEventHandler) Events [ModeChangingEvent];
266 if (!IsBoundUsingDataSourceID)
267 throw new HttpException (String.Format (unhandledEventExceptionMessage, ID, "ModeChanging"));
270 protected virtual void OnItemUpdated (FormViewUpdatedEventArgs e)
272 if (Events != null) {
273 FormViewUpdatedEventHandler eh = (FormViewUpdatedEventHandler) Events [ItemUpdatedEvent];
274 if (eh != null) eh (this, e);
278 protected virtual void OnItemUpdating (FormViewUpdateEventArgs e)
280 if (Events != null) {
281 FormViewUpdateEventHandler eh = (FormViewUpdateEventHandler) Events [ItemUpdatingEvent];
287 if (!IsBoundUsingDataSourceID)
288 throw new HttpException (String.Format (unhandledEventExceptionMessage, ID, "ItemUpdating"));
292 [WebCategoryAttribute ("Paging")]
293 [DefaultValueAttribute (false)]
294 public virtual bool AllowPaging {
296 object ob = ViewState ["AllowPaging"];
302 ViewState ["AllowPaging"] = value;
307 [UrlPropertyAttribute]
308 [WebCategoryAttribute ("Appearance")]
309 [DefaultValueAttribute ("")]
310 [EditorAttribute ("System.Web.UI.Design.ImageUrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
311 public virtual string BackImageUrl {
313 if (ControlStyleCreated)
314 return ((TableStyle) ControlStyle).BackImageUrl;
318 ((TableStyle) ControlStyle).BackImageUrl = value;
322 [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
323 [BrowsableAttribute (false)]
324 public virtual FormViewRow BottomPagerRow {
326 EnsureChildControls ();
327 return bottomPagerRow;
331 [WebCategoryAttribute ("Accessibility")]
332 [DefaultValueAttribute ("")]
333 [LocalizableAttribute (true)]
334 public virtual string Caption {
336 object ob = ViewState ["Caption"];
342 ViewState ["Caption"] = value;
347 [WebCategoryAttribute ("Accessibility")]
348 [DefaultValueAttribute (TableCaptionAlign.NotSet)]
349 public virtual TableCaptionAlign CaptionAlign {
351 object o = ViewState ["CaptionAlign"];
353 return (TableCaptionAlign) o;
354 return TableCaptionAlign.NotSet;
357 ViewState ["CaptionAlign"] = value;
362 [WebCategoryAttribute ("Layout")]
363 [DefaultValueAttribute (-1)]
364 public virtual int CellPadding {
366 if (ControlStyleCreated)
367 return ((TableStyle) ControlStyle).CellPadding;
370 set { ((TableStyle) ControlStyle).CellPadding = value; }
373 [WebCategoryAttribute ("Layout")]
374 [DefaultValueAttribute (0)]
375 public virtual int CellSpacing {
377 if (ControlStyleCreated)
378 return ((TableStyle) ControlStyle).CellSpacing;
382 set { ((TableStyle) ControlStyle).CellSpacing = value; }
385 [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
386 [BrowsableAttribute (false)]
387 public FormViewMode CurrentMode {
388 get { return hasCurrentMode ? currentMode : DefaultMode; }
390 hasCurrentMode = true;
395 FormViewMode defaultMode;
397 [DefaultValueAttribute (FormViewMode.ReadOnly)]
398 [WebCategoryAttribute ("Behavior")]
399 public virtual FormViewMode DefaultMode {
400 get { return defaultMode; }
407 string[] dataKeyNames;
408 [DefaultValueAttribute (null)]
409 [WebCategoryAttribute ("Data")]
410 [TypeConverter (typeof(StringArrayConverter))]
411 [EditorAttribute ("System.Web.UI.Design.WebControls.DataFieldEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
412 public virtual string[] DataKeyNames {
414 if (dataKeyNames == null)
419 dataKeyNames = value;
424 IOrderedDictionary KeyTable {
426 if (_keyTable == null)
427 _keyTable = new OrderedDictionary (DataKeyNames.Length);
432 [BrowsableAttribute (false)]
433 [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
434 public virtual DataKey DataKey {
437 key= new DataKey (KeyTable);
442 DataKey OldEditValues {
444 if (oldEditValues == null)
445 oldEditValues = new DataKey (new OrderedDictionary ());
446 return oldEditValues;
450 [DefaultValue (null)]
451 [TemplateContainer (typeof(FormView), BindingDirection.TwoWay)]
452 [PersistenceMode (PersistenceMode.InnerProperty)]
454 public virtual ITemplate EditItemTemplate {
455 get { return editItemTemplate; }
456 set { editItemTemplate = value; }
459 [WebCategoryAttribute ("Styles")]
460 [PersistenceMode (PersistenceMode.InnerProperty)]
461 [NotifyParentProperty (true)]
462 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
463 [DefaultValueAttribute (null)]
464 public TableItemStyle EditRowStyle {
466 if (editRowStyle == null) {
467 editRowStyle = new TableItemStyle ();
468 if (IsTrackingViewState)
469 editRowStyle.TrackViewState();
475 [WebCategoryAttribute ("Styles")]
476 [PersistenceMode (PersistenceMode.InnerProperty)]
477 [NotifyParentProperty (true)]
478 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
479 [DefaultValueAttribute (null)]
480 public TableItemStyle EmptyDataRowStyle {
482 if (emptyDataRowStyle == null) {
483 emptyDataRowStyle = new TableItemStyle ();
484 if (IsTrackingViewState)
485 emptyDataRowStyle.TrackViewState();
487 return emptyDataRowStyle;
491 [DefaultValue (null)]
492 [TemplateContainer (typeof(FormView), BindingDirection.OneWay)]
493 [PersistenceMode (PersistenceMode.InnerProperty)]
495 public virtual ITemplate EmptyDataTemplate {
496 get { return emptyDataTemplate; }
497 set { emptyDataTemplate = value; }
500 [LocalizableAttribute (true)]
501 [WebCategoryAttribute ("Appearance")]
502 [DefaultValueAttribute ("")]
503 public virtual string EmptyDataText {
505 object ob = ViewState ["EmptyDataText"];
511 ViewState ["EmptyDataText"] = value;
516 [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
517 [BrowsableAttribute (false)]
518 public virtual FormViewRow FooterRow {
520 EnsureChildControls ();
525 [DefaultValue (null)]
526 [TemplateContainer (typeof(FormView), BindingDirection.OneWay)]
527 [PersistenceMode (PersistenceMode.InnerProperty)]
529 public virtual ITemplate FooterTemplate {
530 get { return footerTemplate; }
531 set { footerTemplate = value; }
534 [LocalizableAttribute (true)]
535 [WebCategoryAttribute ("Appearance")]
536 [DefaultValueAttribute ("")]
537 public virtual string FooterText {
539 object ob = ViewState ["FooterText"];
545 ViewState ["FooterText"] = value;
550 [WebCategoryAttribute ("Styles")]
551 [PersistenceMode (PersistenceMode.InnerProperty)]
552 [NotifyParentProperty (true)]
553 [DefaultValue (null)]
554 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
555 public TableItemStyle FooterStyle {
557 if (footerStyle == null) {
558 footerStyle = new TableItemStyle ();
559 if (IsTrackingViewState)
560 footerStyle.TrackViewState();
566 [WebCategoryAttribute ("Appearance")]
567 [DefaultValueAttribute (GridLines.None)]
568 public virtual GridLines GridLines {
570 if (ControlStyleCreated)
571 return ((TableStyle) ControlStyle).GridLines;
572 return GridLines.None;
574 set { ((TableStyle) ControlStyle).GridLines = value; }
577 [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
578 [BrowsableAttribute (false)]
579 public virtual FormViewRow HeaderRow {
581 EnsureChildControls ();
586 [WebCategoryAttribute ("Styles")]
587 [PersistenceMode (PersistenceMode.InnerProperty)]
588 [NotifyParentProperty (true)]
589 [DefaultValue (null)]
590 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
591 public TableItemStyle HeaderStyle {
593 if (headerStyle == null) {
594 headerStyle = new TableItemStyle ();
595 if (IsTrackingViewState)
596 headerStyle.TrackViewState();
602 [DefaultValue (null)]
603 [TemplateContainer (typeof(FormView), BindingDirection.OneWay)]
604 [PersistenceMode (PersistenceMode.InnerProperty)]
606 public virtual ITemplate HeaderTemplate {
607 get { return headerTemplate; }
608 set { headerTemplate = value; }
611 [LocalizableAttribute (true)]
612 [WebCategoryAttribute ("Appearance")]
613 [DefaultValueAttribute ("")]
614 public virtual string HeaderText {
616 object ob = ViewState ["HeaderText"];
622 ViewState ["HeaderText"] = value;
627 [Category ("Layout")]
628 [DefaultValueAttribute (HorizontalAlign.NotSet)]
629 public virtual HorizontalAlign HorizontalAlign {
631 if (ControlStyleCreated)
632 return ((TableStyle) ControlStyle).HorizontalAlign;
633 return HorizontalAlign.NotSet;
635 set { ((TableStyle) ControlStyle).HorizontalAlign = value; }
638 [DefaultValue (null)]
639 [TemplateContainer (typeof(FormView), BindingDirection.TwoWay)]
640 [PersistenceMode (PersistenceMode.InnerProperty)]
642 public virtual ITemplate InsertItemTemplate {
643 get { return insertItemTemplate; }
644 set { insertItemTemplate = value; }
647 [WebCategoryAttribute ("Styles")]
648 [PersistenceMode (PersistenceMode.InnerProperty)]
649 [NotifyParentProperty (true)]
650 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
651 [DefaultValueAttribute (null)]
652 public TableItemStyle InsertRowStyle {
654 if (insertRowStyle == null) {
655 insertRowStyle = new TableItemStyle ();
656 if (IsTrackingViewState)
657 insertRowStyle.TrackViewState();
659 return insertRowStyle;
663 [DefaultValue (null)]
664 [TemplateContainer (typeof(FormView), BindingDirection.TwoWay)]
665 [PersistenceMode (PersistenceMode.InnerProperty)]
667 public virtual ITemplate ItemTemplate {
668 get { return itemTemplate; }
669 set { itemTemplate = value; }
672 [BrowsableAttribute (false)]
673 [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
674 public virtual int PageCount {
675 get { return pageCount; }
676 private set { pageCount = value; }
679 [WebCategoryAttribute ("Paging")]
680 [BindableAttribute (true, BindingDirection.OneWay)]
681 [DefaultValueAttribute (0)]
682 public virtual int PageIndex {
683 get { return pageIndex; }
686 throw new ArgumentOutOfRangeException ("PageIndex must be non-negative");
687 if (pageIndex == value || value == -1)
694 [WebCategoryAttribute ("Paging")]
695 [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Content)]
696 [NotifyParentPropertyAttribute (true)]
697 [PersistenceModeAttribute (PersistenceMode.InnerProperty)]
698 public virtual PagerSettings PagerSettings {
700 if (pagerSettings == null) {
701 pagerSettings = new PagerSettings (this);
702 if (IsTrackingViewState)
703 ((IStateManager)pagerSettings).TrackViewState ();
705 return pagerSettings;
709 [WebCategoryAttribute ("Styles")]
710 [PersistenceMode (PersistenceMode.InnerProperty)]
711 [NotifyParentProperty (true)]
712 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
713 public TableItemStyle PagerStyle {
715 if (pagerStyle == null) {
716 pagerStyle = new TableItemStyle ();
717 if (IsTrackingViewState)
718 pagerStyle.TrackViewState();
725 [DefaultValue (null)]
726 [TemplateContainerAttribute (typeof (FormView))]
727 [PersistenceMode (PersistenceMode.InnerProperty)]
729 public virtual ITemplate PagerTemplate {
730 get { return pagerTemplate; }
731 set { pagerTemplate = value; }
734 [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
735 [BrowsableAttribute (false)]
736 public virtual FormViewRow Row {
738 EnsureChildControls ();
743 [WebCategoryAttribute ("Styles")]
744 [PersistenceMode (PersistenceMode.InnerProperty)]
745 [NotifyParentProperty (true)]
746 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
747 [DefaultValue (null)]
748 public TableItemStyle RowStyle {
750 if (rowStyle == null) {
751 rowStyle = new TableItemStyle ();
752 if (IsTrackingViewState)
753 rowStyle.TrackViewState();
759 [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
760 [BrowsableAttribute (false)]
761 public object SelectedValue {
762 get { return DataKey.Value; }
765 [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
766 [BrowsableAttribute (false)]
767 public virtual FormViewRow TopPagerRow {
769 EnsureChildControls ();
774 [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
775 [BrowsableAttribute (false)]
776 public virtual object DataItem {
777 get { return dataItem; }
780 [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
781 [BrowsableAttribute (false)]
782 public int DataItemCount {
783 get { return PageCount; }
786 [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
787 [BrowsableAttribute (false)]
788 public virtual int DataItemIndex {
789 get { return PageIndex; }
792 int IDataItemContainer.DataItemIndex {
793 get { return DataItemIndex; }
796 int IDataItemContainer.DisplayIndex {
797 get { return PageIndex; }
800 [MonoTODO ("Make use of it in the code")]
801 [DefaultValue (true)]
802 public virtual bool EnableModelValidation {
806 [DefaultValue (true)]
807 public virtual bool RenderOuterTable {
808 get { return renderOuterTable; }
809 set { renderOuterTable = value; }
812 DataBoundControlMode IDataBoundItemControl.Mode {
814 switch (CurrentMode) {
815 case FormViewMode.ReadOnly:
816 return DataBoundControlMode.ReadOnly;
818 case FormViewMode.Edit:
819 return DataBoundControlMode.Edit;
821 case FormViewMode.Insert:
822 return DataBoundControlMode.Insert;
825 throw new InvalidOperationException ("Unsupported mode value.");
830 protected internal virtual string ModifiedOuterTableStylePropertyName ()
832 if (BackImageUrl != String.Empty)
833 return "BackImageUrl";
835 if (CellPadding != -1)
836 return "CellPadding";
838 if (CellSpacing != 0)
839 return "CellSpacing";
841 if (GridLines != GridLines.None)
844 if (HorizontalAlign != HorizontalAlign.NotSet)
845 return "HorizontalAlign";
847 if (ControlStyle.CheckBit ((int)global::System.Web.UI.WebControls.Style.Styles.FontAll))
853 internal override string InlinePropertiesSet ()
855 string baseProps = base.InlinePropertiesSet ();
856 string props = ModifiedOuterTableStylePropertyName ();
857 if (String.IsNullOrEmpty (props))
860 if (String.IsNullOrEmpty (baseProps))
863 return baseProps + ", " + props;
865 public virtual bool IsBindableType (Type type)
867 return type.IsPrimitive || type == typeof (string) || type == typeof (DateTime) || type == typeof (Guid) || type == typeof (Decimal);
870 protected override DataSourceSelectArguments CreateDataSourceSelectArguments ()
872 DataSourceSelectArguments arg = new DataSourceSelectArguments ();
873 DataSourceView view = GetData ();
874 if (AllowPaging && view.CanPage) {
875 arg.StartRowIndex = PageIndex;
876 if (view.CanRetrieveTotalRowCount) {
877 arg.RetrieveTotalRowCount = true;
880 arg.MaximumRows = -1;
885 protected virtual FormViewRow CreateRow (int itemIndex, DataControlRowType rowType, DataControlRowState rowState)
887 if (rowType == DataControlRowType.Pager)
888 return new FormViewPagerRow (itemIndex, rowType, rowState);
890 return new FormViewRow (itemIndex, rowType, rowState);
893 void RequireBinding ()
896 RequiresDataBinding = true;
899 protected virtual Table CreateTable ()
901 return new ContainedTable (this);
904 protected override void EnsureDataBound ()
906 if (CurrentMode == FormViewMode.Insert) {
907 if (RequiresDataBinding) {
908 OnDataBinding (EventArgs.Empty);
909 RequiresDataBinding = false;
910 InternalPerformDataBinding (null);
912 OnDataBound (EventArgs.Empty);
915 base.EnsureDataBound ();
918 protected override Style CreateControlStyle ()
920 TableStyle style = new TableStyle (ViewState);
921 style.CellSpacing = 0;
925 protected override int CreateChildControls (IEnumerable dataSource, bool dataBinding)
927 PagedDataSource pagedDataSource = new PagedDataSource ();
928 pagedDataSource.DataSource = CurrentMode != FormViewMode.Insert ? dataSource : null;
929 pagedDataSource.AllowPaging = AllowPaging;
930 pagedDataSource.PageSize = 1;
931 pagedDataSource.CurrentPageIndex = PageIndex;
933 if (dataBinding && CurrentMode != FormViewMode.Insert) {
934 DataSourceView view = GetData ();
935 if (view != null && view.CanPage) {
936 pagedDataSource.AllowServerPaging = true;
937 if (SelectArguments.RetrieveTotalRowCount)
938 pagedDataSource.VirtualCount = SelectArguments.TotalRowCount;
942 PagerSettings pagerSettings = PagerSettings;
943 bool showPager = AllowPaging && pagerSettings.Visible && (pagedDataSource.PageCount > 1);
946 table = CreateTable ();
947 Controls.Add (table);
951 bottomPagerRow = null;
953 // Gets the current data item
956 PageCount = pagedDataSource.DataSourceCount;
957 if (PageIndex >= PageCount && PageCount > 0)
958 pageIndex = pagedDataSource.CurrentPageIndex = PageCount - 1;
960 if (pagedDataSource.DataSource != null) {
961 IEnumerator e = pagedDataSource.GetEnumerator ();
963 dataItem = e.Current;
967 object lastItem = null;
968 if (pagedDataSource.DataSource != null) {
969 IEnumerator e = pagedDataSource.GetEnumerator ();
970 for (; e.MoveNext (); page++) {
971 lastItem = e.Current;
972 if (page == PageIndex)
973 dataItem = e.Current;
977 if (PageIndex >= PageCount && PageCount > 0) {
978 pageIndex = PageCount - 1;
983 // Main table creation
984 bool emptyRow = PageCount == 0 && CurrentMode != FormViewMode.Insert;
987 headerRow = CreateRow (-1, DataControlRowType.Header, DataControlRowState.Normal);
988 InitializeRow (headerRow);
989 table.Rows.Add (headerRow);
992 if (showPager && pagerSettings.Position == PagerPosition.Top || pagerSettings.Position == PagerPosition.TopAndBottom) {
993 topPagerRow = CreateRow (-1, DataControlRowType.Pager, DataControlRowState.Normal);
994 InitializePager (topPagerRow, pagedDataSource);
995 table.Rows.Add (topPagerRow);
999 DataControlRowState rstate = GetRowState ();
1000 itemRow = CreateRow (0, DataControlRowType.DataRow, rstate);
1001 InitializeRow (itemRow);
1002 table.Rows.Add (itemRow);
1004 switch (CurrentMode) {
1005 case FormViewMode.Edit:
1006 itemRow = CreateRow (-1, DataControlRowType.EmptyDataRow, DataControlRowState.Edit);
1008 case FormViewMode.Insert:
1009 itemRow = CreateRow (-1, DataControlRowType.DataRow, DataControlRowState.Insert);
1012 itemRow = CreateRow (-1, DataControlRowType.EmptyDataRow, DataControlRowState.Normal);
1015 InitializeRow (itemRow);
1016 table.Rows.Add (itemRow);
1020 footerRow = CreateRow (-1, DataControlRowType.Footer, DataControlRowState.Normal);
1021 InitializeRow (footerRow);
1022 table.Rows.Add (footerRow);
1025 if (showPager && pagerSettings.Position == PagerPosition.Bottom || pagerSettings.Position == PagerPosition.TopAndBottom) {
1026 bottomPagerRow = CreateRow (0, DataControlRowType.Pager, DataControlRowState.Normal);
1027 InitializePager (bottomPagerRow, pagedDataSource);
1028 table.Rows.Add (bottomPagerRow);
1031 OnItemCreated (EventArgs.Empty);
1039 DataControlRowState GetRowState ()
1041 DataControlRowState rstate = DataControlRowState.Normal;
1042 if (CurrentMode == FormViewMode.Edit)
1043 rstate |= DataControlRowState.Edit;
1044 else if (CurrentMode == FormViewMode.Insert)
1045 rstate |= DataControlRowState.Insert;
1049 protected virtual void InitializePager (FormViewRow row, PagedDataSource pagedDataSource)
1051 TableCell cell = new TableCell ();
1052 cell.ColumnSpan = 2;
1054 if (pagerTemplate != null)
1055 pagerTemplate.InstantiateIn (cell);
1057 cell.Controls.Add (PagerSettings.CreatePagerControl (pagedDataSource.CurrentPageIndex, pagedDataSource.PageCount));
1059 row.Cells.Add (cell);
1062 protected virtual void InitializeRow (FormViewRow row)
1064 TableCell cell = new TableCell ();
1065 if (row.RowType == DataControlRowType.DataRow) {
1066 if ((row.RowState & DataControlRowState.Edit) != 0) {
1067 if (editItemTemplate != null)
1068 editItemTemplate.InstantiateIn (cell);
1070 row.Visible = false;
1071 } else if ((row.RowState & DataControlRowState.Insert) != 0) {
1072 if (insertItemTemplate != null)
1073 insertItemTemplate.InstantiateIn (cell);
1075 row.Visible = false;
1076 } else if (itemTemplate != null)
1077 itemTemplate.InstantiateIn (cell);
1079 row.Visible = false;
1080 } else if (row.RowType == DataControlRowType.EmptyDataRow) {
1081 if (emptyDataTemplate != null)
1082 emptyDataTemplate.InstantiateIn (cell);
1083 else if (!String.IsNullOrEmpty (EmptyDataText))
1084 cell.Text = EmptyDataText;
1086 row.Visible = false;
1087 } else if (row.RowType == DataControlRowType.Footer)
1089 if (footerTemplate != null)
1090 footerTemplate.InstantiateIn (cell);
1091 else if (!String.IsNullOrEmpty (FooterText))
1092 cell.Text = FooterText;
1094 row.Visible = false;
1095 } else if (row.RowType == DataControlRowType.Header)
1097 if (headerTemplate != null)
1098 headerTemplate.InstantiateIn (cell);
1099 else if (!String.IsNullOrEmpty (HeaderText))
1100 cell.Text = HeaderText;
1102 row.Visible = false;
1104 cell.ColumnSpan = 2;
1105 row.Cells.Add (cell);
1106 row.RenderJustCellContents = !RenderOuterTable;
1109 void FillRowDataKey (object dataItem)
1113 if (cachedKeyProperties == null) {
1114 PropertyDescriptorCollection props = TypeDescriptor.GetProperties (dataItem);
1115 cachedKeyProperties = new PropertyDescriptor [DataKeyNames.Length];
1116 for (int n=0; n<DataKeyNames.Length; n++) {
1117 PropertyDescriptor p = props.Find (DataKeyNames [n], true);
1119 throw new InvalidOperationException ("Property '" + DataKeyNames[n] + "' not found in object of type " + dataItem.GetType());
1120 cachedKeyProperties [n] = p;
1123 foreach (PropertyDescriptor p in cachedKeyProperties)
1124 KeyTable [p.Name] = p.GetValue (dataItem);
1127 IOrderedDictionary GetRowValues (bool includePrimaryKey)
1129 OrderedDictionary dic = new OrderedDictionary ();
1130 ExtractRowValues (dic, includePrimaryKey);
1134 protected virtual void ExtractRowValues (IOrderedDictionary fieldValues, bool includeKeys)
1136 FormViewRow row = Row;
1140 DataControlRowState rowState = row.RowState;
1141 IBindableTemplate bt;
1143 if ((rowState & DataControlRowState.Insert) != 0)
1144 bt = insertItemTemplate as IBindableTemplate;
1145 else if ((rowState & DataControlRowState.Edit) != 0)
1146 bt = editItemTemplate as IBindableTemplate;
1151 IOrderedDictionary values = bt.ExtractValues (row.Cells [0]);
1152 if (values != null) {
1153 foreach (DictionaryEntry e in values) {
1154 if (includeKeys || Array.IndexOf (DataKeyNames, e.Key) == -1)
1155 fieldValues [e.Key] = e.Value;
1161 protected override HtmlTextWriterTag TagKey {
1162 get { return HtmlTextWriterTag.Table; }
1165 public sealed override void DataBind ()
1167 cachedKeyProperties = null;
1170 if (pageCount > 0) {
1171 if (CurrentMode == FormViewMode.Edit)
1172 oldEditValues = new DataKey (GetRowValues (true));
1173 FillRowDataKey (dataItem);
1174 key = new DataKey (KeyTable);
1178 protected internal override void PerformDataBinding (IEnumerable data)
1180 base.PerformDataBinding (data);
1183 protected internal virtual void PrepareControlHierarchy ()
1188 table.Caption = Caption;
1189 table.CaptionAlign = CaptionAlign;
1191 foreach (FormViewRow row in table.Rows) {
1192 switch (row.RowType) {
1193 case DataControlRowType.Header:
1194 if (headerStyle != null && !headerStyle.IsEmpty)
1195 row.ControlStyle.CopyFrom (headerStyle);
1197 case DataControlRowType.Footer:
1198 if (footerStyle != null && !footerStyle.IsEmpty)
1199 row.ControlStyle.CopyFrom (footerStyle);
1201 case DataControlRowType.Pager:
1202 if (pagerStyle != null && !pagerStyle.IsEmpty)
1203 row.ControlStyle.CopyFrom (pagerStyle);
1205 case DataControlRowType.EmptyDataRow:
1206 if (emptyDataRowStyle != null && !emptyDataRowStyle.IsEmpty)
1207 row.ControlStyle.CopyFrom (emptyDataRowStyle);
1209 case DataControlRowType.DataRow:
1210 if (rowStyle != null && !rowStyle.IsEmpty)
1211 row.ControlStyle.CopyFrom (rowStyle);
1212 if ((row.RowState & (DataControlRowState.Edit | DataControlRowState.Insert)) != 0 && editRowStyle != null && !editRowStyle.IsEmpty)
1213 row.ControlStyle.CopyFrom (editRowStyle);
1214 if ((row.RowState & DataControlRowState.Insert) != 0 && insertRowStyle != null && !insertRowStyle.IsEmpty)
1215 row.ControlStyle.CopyFrom (insertRowStyle);
1223 protected internal override void OnInit (EventArgs e)
1225 Page.RegisterRequiresControlState (this);
1229 protected override bool OnBubbleEvent (object source, EventArgs e)
1231 FormViewCommandEventArgs args = e as FormViewCommandEventArgs;
1233 bool causesValidation = false;
1234 IButtonControl button = args.CommandSource as IButtonControl;
1235 if (button != null && button.CausesValidation) {
1236 Page.Validate (button.ValidationGroup);
1237 causesValidation = true;
1239 ProcessCommand (args, causesValidation);
1242 return base.OnBubbleEvent (source, e);
1245 void ProcessCommand (FormViewCommandEventArgs args, bool causesValidation)
1247 OnItemCommand (args);
1248 ProcessEvent (args.CommandName, args.CommandArgument as string, causesValidation);
1251 void IPostBackEventHandler.RaisePostBackEvent (string eventArgument)
1253 RaisePostBackEvent (eventArgument);
1256 protected virtual void RaisePostBackEvent (string eventArgument)
1258 int i = eventArgument.IndexOf ('$');
1259 CommandEventArgs arg;
1261 arg = new CommandEventArgs (eventArgument.Substring (0, i), eventArgument.Substring (i + 1));
1263 arg = new CommandEventArgs (eventArgument, null);
1264 ProcessCommand (new FormViewCommandEventArgs (this, arg), false);
1267 void ProcessEvent (string eventName, string param, bool causesValidation)
1269 switch (eventName) {
1270 case DataControlCommands.PageCommandName:
1273 case DataControlCommands.FirstPageCommandArgument:
1276 case DataControlCommands.LastPageCommandArgument:
1277 newIndex = PageCount - 1;
1279 case DataControlCommands.NextPageCommandArgument:
1280 newIndex = PageIndex + 1;
1282 case DataControlCommands.PreviousPageCommandArgument:
1283 newIndex = PageIndex - 1;
1287 int.TryParse (param, out paramIndex);
1288 newIndex = paramIndex - 1;
1291 SetPageIndex (newIndex);
1294 case DataControlCommands.FirstPageCommandArgument:
1298 case DataControlCommands.LastPageCommandArgument:
1299 SetPageIndex (PageCount - 1);
1302 case DataControlCommands.NextPageCommandArgument:
1303 if (PageIndex < PageCount - 1)
1304 SetPageIndex (PageIndex + 1);
1307 case DataControlCommands.PreviousPageCommandArgument:
1309 SetPageIndex (PageIndex - 1);
1312 case DataControlCommands.EditCommandName:
1313 ProcessChangeMode (FormViewMode.Edit, false);
1316 case DataControlCommands.NewCommandName:
1317 ProcessChangeMode (FormViewMode.Insert, false);
1320 case DataControlCommands.UpdateCommandName:
1321 UpdateItem (param, causesValidation);
1324 case DataControlCommands.CancelCommandName:
1328 case DataControlCommands.DeleteCommandName:
1332 case DataControlCommands.InsertCommandName:
1333 InsertItem (causesValidation);
1338 void SetPageIndex (int index)
1340 FormViewPageEventArgs args = new FormViewPageEventArgs (index);
1341 OnPageIndexChanging (args);
1343 if (args.Cancel || !IsBoundUsingDataSourceID)
1346 int newIndex = args.NewPageIndex;
1347 if (newIndex < 0 || newIndex >= PageCount)
1349 EndRowEdit (false, false);
1350 PageIndex = newIndex;
1351 OnPageIndexChanged (EventArgs.Empty);
1354 public void ChangeMode (FormViewMode newMode)
1356 if (CurrentMode == newMode)
1358 CurrentMode = newMode;
1362 void ProcessChangeMode (FormViewMode newMode, bool cancelingEdit)
1364 FormViewModeEventArgs args = new FormViewModeEventArgs (newMode, cancelingEdit);
1365 OnModeChanging (args);
1367 if (args.Cancel || !IsBoundUsingDataSourceID)
1370 ChangeMode (args.NewMode);
1372 OnModeChanged (EventArgs.Empty);
1377 EndRowEdit (true, true);
1380 public virtual void UpdateItem (bool causesValidation)
1382 UpdateItem (null, causesValidation);
1385 void UpdateItem (string param, bool causesValidation)
1387 if (causesValidation && Page != null && !Page.IsValid)
1390 if (currentMode != FormViewMode.Edit)
1391 throw new HttpException ("Must be in Edit mode");
1393 currentEditOldValues = OldEditValues.Values;
1394 currentEditRowKeys = DataKey.Values;
1395 currentEditNewValues = GetRowValues (true);
1397 FormViewUpdateEventArgs args = new FormViewUpdateEventArgs (param, currentEditRowKeys, currentEditOldValues, currentEditNewValues);
1398 OnItemUpdating (args);
1400 if (args.Cancel || !IsBoundUsingDataSourceID)
1403 DataSourceView view = GetData ();
1405 throw new HttpException ("The DataSourceView associated to data bound control was null");
1406 view.Update (currentEditRowKeys, currentEditNewValues, currentEditOldValues, new DataSourceViewOperationCallback (UpdateCallback));
1409 bool UpdateCallback (int recordsAffected, Exception exception)
1411 FormViewUpdatedEventArgs dargs = new FormViewUpdatedEventArgs (recordsAffected, exception, currentEditRowKeys, currentEditOldValues, currentEditNewValues);
1412 OnItemUpdated (dargs);
1414 if (!dargs.KeepInEditMode)
1415 EndRowEdit (true, false);
1417 return dargs.ExceptionHandled;
1420 public virtual void InsertItem (bool causesValidation)
1422 InsertItem (null, causesValidation);
1425 void InsertItem (string param, bool causesValidation)
1427 if (causesValidation && Page != null && !Page.IsValid)
1430 if (currentMode != FormViewMode.Insert)
1431 throw new HttpException ("Must be in Insert mode");
1433 currentEditNewValues = GetRowValues (true);
1434 FormViewInsertEventArgs args = new FormViewInsertEventArgs (param, currentEditNewValues);
1435 OnItemInserting (args);
1437 if (args.Cancel || !IsBoundUsingDataSourceID)
1440 DataSourceView view = GetData ();
1442 throw new HttpException ("The DataSourceView associated to data bound control was null");
1443 view.Insert (currentEditNewValues, new DataSourceViewOperationCallback (InsertCallback));
1446 bool InsertCallback (int recordsAffected, Exception exception)
1448 FormViewInsertedEventArgs dargs = new FormViewInsertedEventArgs (recordsAffected, exception, currentEditNewValues);
1449 OnItemInserted (dargs);
1451 if (!dargs.KeepInInsertMode)
1452 EndRowEdit (true, false);
1454 return dargs.ExceptionHandled;
1457 public virtual void DeleteItem ()
1459 currentEditRowKeys = DataKey.Values;
1460 currentEditNewValues = GetRowValues (true);
1462 FormViewDeleteEventArgs args = new FormViewDeleteEventArgs (PageIndex, currentEditRowKeys, currentEditNewValues);
1463 OnItemDeleting (args);
1465 if (args.Cancel || !IsBoundUsingDataSourceID)
1468 if (PageIndex > 0 && PageIndex == PageCount - 1)
1473 DataSourceView view = GetData ();
1475 view.Delete (currentEditRowKeys, currentEditNewValues, new DataSourceViewOperationCallback (DeleteCallback));
1477 FormViewDeletedEventArgs dargs = new FormViewDeletedEventArgs (0, null, currentEditRowKeys, currentEditNewValues);
1478 OnItemDeleted (dargs);
1482 bool DeleteCallback (int recordsAffected, Exception exception)
1484 FormViewDeletedEventArgs dargs = new FormViewDeletedEventArgs (recordsAffected, exception, currentEditRowKeys, currentEditNewValues);
1485 OnItemDeleted (dargs);
1486 return dargs.ExceptionHandled;
1489 void EndRowEdit (bool switchToDefaultMode, bool cancelingEdit)
1491 if (switchToDefaultMode)
1492 ProcessChangeMode (DefaultMode, cancelingEdit);
1493 oldEditValues = new DataKey (new OrderedDictionary ());
1494 currentEditRowKeys = null;
1495 currentEditOldValues = null;
1496 currentEditNewValues = null;
1500 protected internal override void LoadControlState (object savedState)
1502 if (savedState == null) return;
1503 object[] state = (object[]) savedState;
1504 base.LoadControlState (state[0]);
1505 pageIndex = (int) state[1];
1506 pageCount = (int) state[2];
1507 CurrentMode = (FormViewMode) state[3];
1508 defaultMode = (FormViewMode) state[4];
1509 dataKeyNames = (string[]) state[5];
1510 if (state [6] != null)
1511 ((IStateManager) DataKey).LoadViewState (state [6]);
1512 if (state [7] != null)
1513 ((IStateManager) OldEditValues).LoadViewState (state [7]);
1516 protected internal override object SaveControlState ()
1518 object bstate = base.SaveControlState ();
1519 return new object [] {
1526 (key == null ? null : ((IStateManager)key).SaveViewState()),
1527 (oldEditValues == null ? null : ((IStateManager) oldEditValues).SaveViewState ())
1531 protected override void TrackViewState()
1533 base.TrackViewState();
1534 if (pagerSettings != null)
1535 ((IStateManager)pagerSettings).TrackViewState();
1536 if (footerStyle != null)
1537 ((IStateManager)footerStyle).TrackViewState();
1538 if (headerStyle != null)
1539 ((IStateManager)headerStyle).TrackViewState();
1540 if (pagerStyle != null)
1541 ((IStateManager)pagerStyle).TrackViewState();
1542 if (rowStyle != null)
1543 ((IStateManager)rowStyle).TrackViewState();
1544 if (editRowStyle != null)
1545 ((IStateManager)editRowStyle).TrackViewState();
1546 if (insertRowStyle != null)
1547 ((IStateManager)insertRowStyle).TrackViewState();
1548 if (emptyDataRowStyle != null)
1549 ((IStateManager)emptyDataRowStyle).TrackViewState();
1552 protected override object SaveViewState()
1554 object[] states = new object [10];
1555 states[0] = base.SaveViewState();
1556 states[1] = (pagerSettings == null ? null : ((IStateManager)pagerSettings).SaveViewState());
1557 states[2] = (footerStyle == null ? null : ((IStateManager)footerStyle).SaveViewState());
1558 states[3] = (headerStyle == null ? null : ((IStateManager)headerStyle).SaveViewState());
1559 states[4] = (pagerStyle == null ? null : ((IStateManager)pagerStyle).SaveViewState());
1560 states[5] = (rowStyle == null ? null : ((IStateManager)rowStyle).SaveViewState());
1561 states[6] = (insertRowStyle == null ? null : ((IStateManager)insertRowStyle).SaveViewState());
1562 states[7] = (editRowStyle == null ? null : ((IStateManager)editRowStyle).SaveViewState());
1563 states[8] = (emptyDataRowStyle == null ? null : ((IStateManager)emptyDataRowStyle).SaveViewState());
1565 for (int i = states.Length - 1; i >= 0; i--) {
1566 if (states [i] != null)
1573 protected override void LoadViewState (object savedState)
1575 if (savedState == null) {
1576 base.LoadViewState (null);
1580 object [] states = (object []) savedState;
1582 base.LoadViewState (states[0]);
1584 if (states[1] != null)
1585 ((IStateManager)PagerSettings).LoadViewState (states[1]);
1586 if (states[2] != null)
1587 ((IStateManager)FooterStyle).LoadViewState (states[2]);
1588 if (states[3] != null)
1589 ((IStateManager)HeaderStyle).LoadViewState (states[3]);
1590 if (states[4] != null)
1591 ((IStateManager)PagerStyle).LoadViewState (states[4]);
1592 if (states[5] != null)
1593 ((IStateManager)RowStyle).LoadViewState (states[5]);
1594 if (states[6] != null)
1595 ((IStateManager)InsertRowStyle).LoadViewState (states[6]);
1596 if (states[7] != null)
1597 ((IStateManager)EditRowStyle).LoadViewState (states[7]);
1598 if (states[8] != null)
1599 ((IStateManager)EmptyDataRowStyle).LoadViewState (states[8]);
1602 protected internal override void Render (HtmlTextWriter writer)
1604 VerifyInlinePropertiesNotSet ();
1605 if (RenderOuterTable) {
1606 PrepareControlHierarchy ();
1608 table.Render (writer);
1609 } else if (table != null)
1610 table.RenderChildren (writer);
1613 PostBackOptions IPostBackContainer.GetPostBackOptions (IButtonControl control)
1615 if (control == null)
1616 throw new ArgumentNullException ("control");
1618 if (control.CausesValidation)
1619 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.");
1621 PostBackOptions options = new PostBackOptions (this);
1622 options.Argument = control.CommandName + "$" + control.CommandArgument;
1623 options.RequiresJavaScriptProtocol = true;