Merge pull request #4621 from alexanderkyte/strdup_env
[mono.git] / mcs / class / System.Web / System.Web.UI.WebControls / DetailsView.cs
index f2999a15cd32a214fc9afdd1c9ddcac455c5441b..af981d0994395f7fb944f5e24164f85185df9482 100644 (file)
@@ -43,12 +43,11 @@ namespace System.Web.UI.WebControls
        [DesignerAttribute ("System.Web.UI.Design.WebControls.DetailsViewDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
        [ControlValuePropertyAttribute ("SelectedValue")]
        [DefaultEventAttribute ("PageIndexChanging")]
+       [DataKeyProperty ("DataKey")]
        [AspNetHostingPermissionAttribute (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
        [AspNetHostingPermissionAttribute (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
        public class DetailsView: CompositeDataBoundControl, ICallbackEventHandler, ICallbackContainer, IDataItemContainer, INamingContainer, IPostBackEventHandler, IPostBackContainer
-#if NET_4_0
                , IDataBoundItemControl, IDataBoundControl, IFieldControl
-#endif
        {
                object dataItem;
                
@@ -297,7 +296,6 @@ namespace System.Web.UI.WebControls
                                throw new HttpException (String.Format (unhandledEventExceptionMessage, ID, "ItemUpdating"));
                }
                
-#if NET_4_0            
                DataBoundControlMode IDataBoundItemControl.Mode {
                        get {
                                switch (CurrentMode) {
@@ -329,7 +327,6 @@ namespace System.Web.UI.WebControls
                                throw new NotImplementedException ();
                        }
                }
-#endif
                [WebCategoryAttribute ("Paging")]
                [DefaultValueAttribute (false)]
                public virtual bool AllowPaging {
@@ -964,14 +961,14 @@ namespace System.Web.UI.WebControls
                int IDataItemContainer.DataItemIndex {
                        get { return DataItemIndex; }
                }
-#if NET_4_0
+
                [MonoTODO ("Make use of it in the code")]
                [DefaultValue (true)]
                public virtual bool EnableModelValidation {
                        get;
                        set;
                }
-#endif
+
                public virtual bool IsBindableType (Type type)
                {
                        return type.IsPrimitive || type == typeof (string) || type == typeof (DateTime) || type == typeof (Guid) || type == typeof (Decimal);
@@ -1112,24 +1109,24 @@ namespace System.Web.UI.WebControls
                        return style;
                }
                
-               protected override int CreateChildControls (IEnumerable data, bool dataBinding)
+               protected override int CreateChildControls (IEnumerable dataSource, bool dataBinding)
                {
-                       PagedDataSource dataSource = new PagedDataSource ();
-                       dataSource.DataSource = CurrentMode != DetailsViewMode.Insert ? data : null;
-                       dataSource.AllowPaging = AllowPaging;
-                       dataSource.PageSize = 1;
-                       dataSource.CurrentPageIndex = PageIndex;
+                       PagedDataSource pagedDataSource = new PagedDataSource ();
+                       pagedDataSource.DataSource = CurrentMode != DetailsViewMode.Insert ? dataSource : null;
+                       pagedDataSource.AllowPaging = AllowPaging;
+                       pagedDataSource.PageSize = 1;
+                       pagedDataSource.CurrentPageIndex = PageIndex;
 
                        if (dataBinding && CurrentMode != DetailsViewMode.Insert) {
                                DataSourceView view = GetData ();
                                if (view != null && view.CanPage) {
-                                       dataSource.AllowServerPaging = true;
+                                       pagedDataSource.AllowServerPaging = true;
                                        if (SelectArguments.RetrieveTotalRowCount)
-                                               dataSource.VirtualCount = SelectArguments.TotalRowCount;
+                                               pagedDataSource.VirtualCount = SelectArguments.TotalRowCount;
                                }
                        }
 
-                       bool showPager = AllowPaging && (dataSource.PageCount > 1);
+                       bool showPager = AllowPaging && (pagedDataSource.PageCount > 1);
 
                        Controls.Clear ();
                        table = CreateTable ();
@@ -1143,19 +1140,19 @@ namespace System.Web.UI.WebControls
                        // Gets the current data item
 
                        if (AllowPaging) {
-                               PageCount = dataSource.DataSourceCount;
+                               PageCount = pagedDataSource.DataSourceCount;
                                if (PageIndex >= PageCount && PageCount > 0)
-                                       pageIndex = dataSource.CurrentPageIndex = PageCount - 1;
-                               if (dataSource.DataSource != null) {
-                                       IEnumerator e = dataSource.GetEnumerator ();
+                                       pageIndex = pagedDataSource.CurrentPageIndex = PageCount - 1;
+                               if (pagedDataSource.DataSource != null) {
+                                       IEnumerator e = pagedDataSource.GetEnumerator ();
                                        if (e.MoveNext ())
                                                dataItem = e.Current;
                                }
                        } else {
                                int page = 0;
                                object lastItem = null;
-                               if (dataSource.DataSource != null) {
-                                       IEnumerator e = dataSource.GetEnumerator ();
+                               if (pagedDataSource.DataSource != null) {
+                                       IEnumerator e = pagedDataSource.GetEnumerator ();
                                        for (; e.MoveNext (); page++) {
                                                lastItem = e.Current;
                                                if (page == PageIndex)
@@ -1205,7 +1202,7 @@ namespace System.Web.UI.WebControls
                                if (showPager && PagerSettings.Position == PagerPosition.Top ||
                                                PagerSettings.Position == PagerPosition.TopAndBottom) {
                                        topPagerRow = CreateRow (-1, DataControlRowType.Pager, DataControlRowState.Normal);
-                                       InitializePager (topPagerRow, dataSource);
+                                       InitializePager (topPagerRow, pagedDataSource);
                                        table.Rows.Add (topPagerRow);
                                }
 
@@ -1232,7 +1229,7 @@ namespace System.Web.UI.WebControls
                                if (showPager && PagerSettings.Position == PagerPosition.Bottom ||
                                                PagerSettings.Position == PagerPosition.TopAndBottom) {
                                        bottomPagerRow = CreateRow (-1, DataControlRowType.Pager, DataControlRowState.Normal);
-                                       InitializePager (bottomPagerRow, dataSource);
+                                       InitializePager (bottomPagerRow, pagedDataSource);
                                        table.Rows.Add (bottomPagerRow);
                                }
                        }
@@ -1271,7 +1268,7 @@ namespace System.Web.UI.WebControls
                        return rstate;
                }
                
-               protected virtual void InitializePager (DetailsViewRow row, PagedDataSource dataSource)
+               protected virtual void InitializePager (DetailsViewRow row, PagedDataSource pagedDataSource)
                {
                        TableCell cell = new TableCell ();
                        cell.ColumnSpan = 2;
@@ -1279,7 +1276,7 @@ namespace System.Web.UI.WebControls
                        if (pagerTemplate != null)
                                pagerTemplate.InstantiateIn (cell);
                        else
-                               cell.Controls.Add (PagerSettings.CreatePagerControl (dataSource.CurrentPageIndex, dataSource.PageCount));
+                               cell.Controls.Add (PagerSettings.CreatePagerControl (pagedDataSource.CurrentPageIndex, pagedDataSource.PageCount));
                        
                        row.Cells.Add (cell);
                }
@@ -1352,7 +1349,7 @@ namespace System.Web.UI.WebControls
                        return dic;
                }
                
-               protected virtual void ExtractRowValues (IOrderedDictionary fieldValues, bool includeReadOnlyFields, bool includePrimaryKey)
+               protected virtual void ExtractRowValues (IOrderedDictionary fieldValues, bool includeReadOnlyFields, bool includeKeys)
                {
                        foreach (DetailsViewRow row in Rows) {
                                if (row.Cells.Count < 1)
@@ -1361,7 +1358,7 @@ namespace System.Web.UI.WebControls
                                if (c != null)
                                        c.ContainingField.ExtractValuesFromCell (fieldValues, c, row.RowState, includeReadOnlyFields);
                        }
-                       if (!includePrimaryKey && DataKeyNames != null)
+                       if (!includeKeys && DataKeyNames != null)
                                foreach (string key in DataKeyNames)
                                        fieldValues.Remove (key);
                }
@@ -1597,12 +1594,10 @@ namespace System.Web.UI.WebControls
                                        break;
                        }
                }
-#if NET_4_0
                public
-#endif
-               void SetPageIndex (int newIndex)
+               void SetPageIndex (int index)
                {
-                       DetailsViewPageEventArgs args = new DetailsViewPageEventArgs (newIndex);
+                       DetailsViewPageEventArgs args = new DetailsViewPageEventArgs (index);
                        OnPageIndexChanging (args);
 
                        if (args.Cancel || !IsBoundUsingDataSourceID)
@@ -1769,11 +1764,11 @@ namespace System.Web.UI.WebControls
                        RequireBinding ();
                }
 
-               protected internal override void LoadControlState (object ob)
+               protected internal override void LoadControlState (object savedState)
                {
-                       if (ob == null)
+                       if (savedState == null)
                                return;
-                       object[] state = (object[]) ob;
+                       object[] state = (object[]) savedState;
                        base.LoadControlState (state[0]);
                        pageIndex = (int) state[1];
                        pageCount = (int) state[2];
@@ -1905,14 +1900,14 @@ namespace System.Web.UI.WebControls
                                ControlStyle.LoadViewState (states [12]);
                }
                
-               void ICallbackEventHandler.RaiseCallbackEvent (string eventArgs)
+               void ICallbackEventHandler.RaiseCallbackEvent (string eventArgument)
                {
-                       RaiseCallbackEvent (eventArgs);
+                       RaiseCallbackEvent (eventArgument);
                }
                
-               protected virtual void RaiseCallbackEvent (string eventArgs)
+               protected virtual void RaiseCallbackEvent (string eventArgument)
                {
-                       string[] clientData = eventArgs.Split ('|');
+                       string[] clientData = eventArgument.Split ('|');
                        PageIndex = int.Parse (clientData[0]);
                        
                        RaisePostBackEvent (clientData[1]);