Exemple #1
0
        private static GridPart FindControls(string masterEditorID, ControlCollection controls,
                                             Enums.GridPart controlTypeSearchFor)
        {
            // Search the children of this control
            for (int i = 0; i < controls.Count; i++)
            {
                if (controls[i] is GridPart == false)
                {
                    continue;
                }

                GridPart found = (GridPart)controls[i];
                if (found.GridPartType != controlTypeSearchFor ||
                    String.Compare(found.MasterGrid, masterEditorID, true) != 0)
                {
                    continue;
                }
                return(found);
            }

            // Start searching the children of the children of this control
            for (int i = 0; i < controls.Count; i++)
            {
                if (controls[i].Controls.Count == 0)
                {
                    continue;
                }

                GridPart found = FindControls(masterEditorID, controls[i].Controls, controlTypeSearchFor);
                if (found != null)
                {
                    return(found);
                }
            }

            // Oops!
            return(null);
        }
Exemple #2
0
 /*
  * private static void FindControls(WebGrid.Grid grid, System.Web.UI.ControlCollection controls,ref WebGrid.GridPart  tagControl, WebGrid.GridPart controlType )
  * {
  *  if( tagControl != null )
  *      return;
  *  for(int i = 0; i < controls.Count; i++)
  *      if( controls[i] is WebGrid.GridPart && ((WebGrid.GridPart)controls[i]).ForeignkeyType == controlType && ((WebGrid.GridPart)controls[i]).MasterGrid == grid.ColumnId )
  *      {
  *          tagControl =  (WebGrid.GridPart)controls[i];
  *      }
  *      else if ( controls[i].Controls.Count > 0 )
  *          FindControls(grid, controls[i].Controls,ref tagControl, controlType );
  * }
  */
 /// <summary>
 /// Gets true if same control type else false.
 /// </summary>
 /// <returns>This object if found, else null</returns>
 /// <param name="controlTypeSearchFor">Control type</param>
 /// <param name="grid">Grid</param>
 internal static GridPart GetControl(Grid grid, Enums.GridPart controlTypeSearchFor)
 {
     return(grid.Page == null ? null : FindControls(grid.ID, grid.Page.Controls, controlTypeSearchFor));
 }