Author: igorz
Date: 2006-10-05 11:02:19 -0400 (Thu, 05 Oct 2006)
New Revision: 66293

Modified:
   trunk/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
   trunk/mcs/class/System.Web/System.Web.UI.WebControls/DetailsView.cs
   trunk/mcs/class/System.Web/System.Web.UI.WebControls/DetailsViewRow.cs
Log:


Modified: trunk/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog      
2006-10-05 14:54:02 UTC (rev 66292)
+++ trunk/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog      
2006-10-05 15:02:19 UTC (rev 66293)
@@ -1,5 +1,12 @@
 2006-10-05 Igor Zelmanovich <[EMAIL PROTECTED]>
 
+       * DetailsView.cs:
+       * DetailsViewRow.cs:
+       implemented PrepareControlHierarchy()
+       styles are applied correct
+
+2006-10-05 Igor Zelmanovich <[EMAIL PROTECTED]>
+
        * FormView.cs:
        implemented PrepareControlHierarchy()
        styles are applied correct

Modified: trunk/mcs/class/System.Web/System.Web.UI.WebControls/DetailsView.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.WebControls/DetailsView.cs 
2006-10-05 14:54:02 UTC (rev 66292)
+++ trunk/mcs/class/System.Web/System.Web.UI.WebControls/DetailsView.cs 
2006-10-05 15:02:19 UTC (rev 66293)
@@ -70,9 +70,6 @@
                PropertyDescriptor[] cachedKeyProperties;
                readonly string[] emptyKeys = new string[0];
                
-               CommandField commandField;
-               DetailsViewRow commandRow;
-                       
                // View state
                DataControlFieldCollection columns;
                PagerSettings pagerSettings;
@@ -365,13 +362,12 @@
                [EditorAttribute ("System.Web.UI.Design.ImageUrlEditor, " + 
Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + 
Consts.AssemblySystem_Drawing)]
                public virtual string BackImageUrl {
                        get {
-                               object ob = ViewState ["BackImageUrl"];
-                               if (ob != null) return (string) ob;
-                               return string.Empty;
+                               if (ControlStyleCreated)
+                                       return ((TableStyle) 
ControlStyle).BackImageUrl;
+                               return String.Empty;
                        }
                        set {
-                               ViewState ["BackImageUrl"] = value;
-                               RequireBinding ();
+                               ((TableStyle) ControlStyle).BackImageUrl = 
value;
                        }
                }
 
@@ -419,15 +415,12 @@
                public virtual int CellPadding
                {
                        get {
-                               object o = ViewState ["CellPadding"];
-                               if (o != null) return (int) o;
+                               if (ControlStyleCreated)
+                                       return ((TableStyle) 
ControlStyle).CellPadding;
                                return -1;
                        }
                        set {
-                               if (value < -1)
-                                       throw new ArgumentOutOfRangeException 
("< -1");
-                               ViewState["CellPadding"] = value;
-                               RequireBinding ();
+                               ((TableStyle) ControlStyle).CellPadding = value;
                        }
                }
 
@@ -436,15 +429,12 @@
                public virtual int CellSpacing
                {
                        get {
-                               object o = ViewState ["CellSpacing"];
-                               if (o != null) return (int) o;
+                               if (ControlStyleCreated)
+                                       return ((TableStyle) 
ControlStyle).CellSpacing;
                                return 0;
                        }
                        set {
-                               if (value < -1)
-                                       throw new ArgumentOutOfRangeException 
("< -1");
-                               ViewState ["CellSpacing"] = value;
-                               RequireBinding ();
+                               ((TableStyle) ControlStyle).CellSpacing = value;
                        }
                }
                
@@ -670,10 +660,12 @@
                [DefaultValueAttribute (GridLines.Both)]
                public virtual GridLines GridLines {
                        get {
-                               return ((TableStyle)ControlStyle).GridLines;
+                               if (ControlStyleCreated)
+                                       return ((TableStyle) 
ControlStyle).GridLines;
+                               return GridLines.Both;
                        }
                        set {
-                               ((TableStyle)ControlStyle).GridLines = value;
+                               ((TableStyle) ControlStyle).GridLines = value;
                        }
                }
 
@@ -730,13 +722,12 @@
                [DefaultValueAttribute (HorizontalAlign.NotSet)]
                public virtual HorizontalAlign HorizontalAlign {
                        get {
-                               object ob = ViewState ["HorizontalAlign"];
-                               if (ob != null) return (HorizontalAlign) ob;
+                               if (ControlStyleCreated)
+                                       return ((TableStyle) 
ControlStyle).HorizontalAlign;
                                return HorizontalAlign.NotSet;
                        }
                        set {
-                               ViewState ["HorizontalAlign"] = value;
-                               RequireBinding ();
+                               ((TableStyle) ControlStyle).HorizontalAlign = 
value;
                        }
                }
 
@@ -919,7 +910,6 @@
                                field.ShowDeleteButton = 
AutoGenerateDeleteButton;
                                field.ShowInsertButton = 
AutoGenerateInsertButton;
                                fields.Add (field);
-                               commandField = field;
                        }
                        
                        return fields;
@@ -986,16 +976,7 @@
                
                protected virtual Table CreateTable ()
                {
-                       Table table = new Table ();
-                       table.Caption = Caption;
-                       table.CaptionAlign = CaptionAlign;
-                       table.CellPadding = CellPadding;
-                       //CellSpacing defaults to 0 and Table.CellSpacing to -1
-                       if (CellSpacing != 0)
-                               table.CellSpacing = CellSpacing;
-                       table.HorizontalAlign = HorizontalAlign;
-                       table.BackImageUrl = BackImageUrl;
-                       return table;
+                       return new ContainedTable (this);
                }
 
                protected override Style CreateControlStyle ()
@@ -1096,9 +1077,6 @@
                                        InitializeRow (row, field);
                                        table.Rows.Add (row);
                                        list.Add (row);
-
-                                       if (commandField == field)
-                                               commandRow = row;
                                }
                                if (!dataBinding) {
                                        if (CurrentMode == DetailsViewMode.Edit)
@@ -1110,12 +1088,6 @@
                        }
 
                        rows = new DetailsViewRowCollection (list);
-                       
-                       if (showPager && PagerSettings.Position == 
PagerPosition.Bottom || PagerSettings.Position == PagerPosition.TopAndBottom) {
-                               bottomPagerRow = CreateRow (-1, 
DataControlRowType.Pager, DataControlRowState.Normal);
-                               InitializePager (bottomPagerRow, dataSource);
-                               table.Rows.Add (bottomPagerRow);
-                       }
 
                        footerRow = CreateRow (-1, DataControlRowType.Footer, 
DataControlRowState.Normal);
                        DataControlFieldCell footerCell = new 
DataControlFieldCell (null);
@@ -1127,6 +1099,12 @@
                        footerRow.Cells.Add (footerCell);
                        table.Rows.Add (footerRow);
                        
+                       if (showPager && PagerSettings.Position == 
PagerPosition.Bottom || PagerSettings.Position == PagerPosition.TopAndBottom) {
+                               bottomPagerRow = CreateRow (-1, 
DataControlRowType.Pager, DataControlRowState.Normal);
+                               InitializePager (bottomPagerRow, dataSource);
+                               table.Rows.Add (bottomPagerRow);
+                       }
+                       
                        if (dataBinding)
                                DataBind (false);
                        
@@ -1177,6 +1155,7 @@
                
                protected virtual void InitializeRow (DetailsViewRow row, 
DataControlField field)
                {
+                       row.ContainingField = field;
                        DataControlFieldCell cell;
                        
                        if (field.ShowHeader) {
@@ -1265,10 +1244,72 @@
                        base.PerformDataBinding (data);
                }
 
-               [MonoTODO]
                protected internal virtual void PrepareControlHierarchy ()
                {
-                       throw new NotImplementedException ();
+                       if (table == null)
+                               return;
+
+                       table.Caption = Caption;
+                       table.CaptionAlign = CaptionAlign;
+
+                       foreach (DetailsViewRow row in table.Rows) {
+                               switch (row.RowType) {
+                               case DataControlRowType.Header:
+                                       if (headerStyle != null && 
!headerStyle.IsEmpty)
+                                               row.ControlStyle.CopyFrom 
(headerStyle);
+                                       break;
+                               case DataControlRowType.Footer:
+                                       if (footerStyle != null && 
!footerStyle.IsEmpty)
+                                               row.ControlStyle.CopyFrom 
(footerStyle);
+                                       break;
+                               case DataControlRowType.Pager:
+                                       if (pagerStyle != null && 
!pagerStyle.IsEmpty)
+                                               row.ControlStyle.CopyFrom 
(pagerStyle);
+                                       break;
+                               case DataControlRowType.EmptyDataRow:
+                                       if (emptyDataRowStyle != null && 
!emptyDataRowStyle.IsEmpty)
+                                               row.ControlStyle.CopyFrom 
(emptyDataRowStyle);
+                                       break;
+                               case DataControlRowType.DataRow:
+                                       if (rowStyle != null && 
!rowStyle.IsEmpty)
+                                               row.ControlStyle.CopyFrom 
(rowStyle);
+                                       if ((row.RowState & 
DataControlRowState.Alternate) != 0 && alternatingRowStyle != null && 
!alternatingRowStyle.IsEmpty)
+                                               row.ControlStyle.CopyFrom 
(alternatingRowStyle);
+                                       if ((row.RowState & 
DataControlRowState.Edit) != 0 && editRowStyle != null && !editRowStyle.IsEmpty)
+                                               row.ControlStyle.CopyFrom 
(editRowStyle);
+                                       if ((row.RowState & 
DataControlRowState.Insert) != 0 && insertRowStyle != null && 
!insertRowStyle.IsEmpty)
+                                               row.ControlStyle.CopyFrom 
(insertRowStyle);
+                                       break;
+                               default:
+                                       break;
+                               }
+
+                               if ((row.ContainingField is CommandField) && 
commandRowStyle != null && !commandRowStyle.IsEmpty)
+                                       row.ControlStyle.CopyFrom 
(commandRowStyle);
+
+                               for (int n = 0; n < row.Cells.Count; n++) {
+                                       DataControlFieldCell fcell = row.Cells 
[n] as DataControlFieldCell;
+                                       if (fcell != null && 
fcell.ContainingField != null) {
+                                               DataControlField field = 
fcell.ContainingField;
+                                               if (n == 0 && field.ShowHeader) 
{
+                                                       if (fieldHeaderStyle != 
null && !fieldHeaderStyle.IsEmpty)
+                                                               
fcell.ControlStyle.CopyFrom (fieldHeaderStyle);
+                                                       if 
(field.HeaderStyleCreated)
+                                                               
fcell.ControlStyle.CopyFrom (field.HeaderStyle);
+                                               }
+                                               else {
+                                                       if 
(field.ControlStyleCreated && !field.ControlStyle.IsEmpty)
+                                                               foreach 
(Control c in fcell.Controls) {
+                                                                       
WebControl wc = c as WebControl;
+                                                                       if (wc 
!= null)
+                                                                               
wc.ControlStyle.MergeWith (field.ControlStyle);
+                                                               }
+                                                       if 
(field.ItemStyleCreated)
+                                                               
fcell.ControlStyle.CopyFrom (field.ItemStyle);
+                                               }
+                                       }
+                               }
+                       }
                }
                
                protected internal override void OnInit (EventArgs e)
@@ -1716,6 +1757,8 @@
                
                protected internal override void Render (HtmlTextWriter writer)
                {
+                       PrepareControlHierarchy ();
+                       
                        if (EnablePagingCallbacks)
                                base.RenderBeginTag (writer);
                        else
@@ -1731,58 +1774,10 @@
                
                void RenderGrid (HtmlTextWriter writer)
                {
-                       table.GridLines = GridLines;
-                       table.ControlStyle.MergeWith (ControlStyle);
-                       table.RenderBeginTag (writer);
-                       
-                       foreach (DetailsViewRow row in table.Rows)
-                       {
-                               switch (row.RowType) {
-                               case DataControlRowType.Header:
-                                       if (headerStyle != 
null)headerStyle.AddAttributesToRender (writer, row);
-                                       break;
-                               case DataControlRowType.Footer:
-                                       if (footerStyle != null) 
footerStyle.AddAttributesToRender (writer, row);
-                                       break;
-                               case DataControlRowType.Pager:
-                                       if (pagerStyle != null) 
pagerStyle.AddAttributesToRender (writer, row);
-                                       break;
-                               case DataControlRowType.EmptyDataRow:
-                                       if (emptyDataRowStyle != null) 
emptyDataRowStyle.AddAttributesToRender (writer, row);
-                                       break;
-                               default:
-                                       if (rowStyle != null) 
rowStyle.AddAttributesToRender (writer, row);
-                                       break;
-                               }
+                       if (table == null)
+                               return;
 
-                               if ((row.RowState & 
DataControlRowState.Alternate) != 0 && alternatingRowStyle != null)
-                                       
alternatingRowStyle.AddAttributesToRender (writer, row);
-                               if ((row.RowState & DataControlRowState.Edit) 
!= 0 && editRowStyle != null)
-                                       editRowStyle.AddAttributesToRender 
(writer, row);
-                               if ((row.RowState & DataControlRowState.Insert) 
!= 0 && insertRowStyle != null)
-                                       insertRowStyle.AddAttributesToRender 
(writer, row);
-                                       
-                               if (row == commandRow && commandRowStyle != 
null)
-                                       commandRowStyle.AddAttributesToRender 
(writer, row);
-                               
-                               row.RenderBeginTag (writer);
-                               
-                               for (int n=0; n<row.Cells.Count; n++) {
-                                       DataControlFieldCell fcell = 
row.Cells[n] as DataControlFieldCell;
-                                       if (fcell != null && 
fcell.ContainingField != null) {
-                                               if (n == 0 && 
fcell.ContainingField.ShowHeader) {
-                                                       if (fieldHeaderStyle != 
null)
-                                                               
fieldHeaderStyle.AddAttributesToRender (writer, fcell);
-                                                       
fcell.ContainingField.HeaderStyle.AddAttributesToRender (writer, fcell);
-                                               }
-                                               else
-                                                       
fcell.ContainingField.ItemStyle.AddAttributesToRender (writer, fcell);
-                                       }
-                                       row.Cells[n].Render (writer);
-                               }
-                               row.RenderEndTag (writer);
-                       }
-                       table.RenderEndTag (writer);
+                       table.Render (writer);
                }
 
 

Modified: trunk/mcs/class/System.Web/System.Web.UI.WebControls/DetailsViewRow.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.WebControls/DetailsViewRow.cs      
2006-10-05 14:54:02 UTC (rev 66292)
+++ trunk/mcs/class/System.Web/System.Web.UI.WebControls/DetailsViewRow.cs      
2006-10-05 15:02:19 UTC (rev 66293)
@@ -45,6 +45,7 @@
                int rowIndex;
                DataControlRowState rowState;
                DataControlRowType rowType;
+               DataControlField containingField;
                
                public DetailsViewRow (int rowIndex, DataControlRowType 
rowType, DataControlRowState rowState)
                {
@@ -65,6 +66,11 @@
                        get { return rowType; }
                }
                
+               internal DataControlField ContainingField {
+                       get { return containingField; }
+                       set { containingField = value; }
+               }
+
                protected override bool OnBubbleEvent (object source, EventArgs 
e)
                {
                        if (base.OnBubbleEvent (source, e)) return true;

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to