private IFilterExpressionProvider FindControl(Control control) { var result = Misc.FindControl(control, ControlID) as IFilterExpressionProvider; if (result == null) { throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, "The control '{0}' could not be found.", ControlID)); } return(result); }
private Control FindTargetControl() { Control control = Misc.FindControl(Owner, ControlID); if (control == null) { throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, DynamicDataResources.ControlFilterExpression_CouldNotFindControlID, Owner.ID, ControlID)); } return(control); }
private void OnPageInit(object sender, EventArgs e) { foreach (DataControlReference controlReference in DataControls) { Control targetControl = Misc.FindControl(this, controlReference.ControlID); if (targetControl == null) { throw new InvalidOperationException( String.Format(CultureInfo.CurrentCulture, DynamicDataResources.DynamicDataManager_ControlNotFound, controlReference.ControlID)); } RegisterControl(targetControl); } }
/// <summary> /// See IWhereParametersProvider.GetWhereParameters /// </summary> public virtual IEnumerable <Parameter> GetWhereParameters(IDynamicDataSource dataSource) { Debug.Assert(dataSource != null); // Find the control that the ControlParameter uses Control control = Misc.FindControl((Control)dataSource, ControlId); if (control == null) { throw new InvalidOperationException(String.Format( CultureInfo.CurrentCulture, DynamicDataResources.DynamicControlParameter_DynamicDataSourceControlNotFound, ControlId)); } // If the control is itself a parameter provider, delegate to it var whereParametersProvider = control as IWhereParametersProvider; if (whereParametersProvider != null) { return(whereParametersProvider.GetWhereParameters(dataSource)); } IControlParameterTarget paramTarget = DynamicDataManager.GetControlParameterTarget(control); if (paramTarget == null) { throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, DynamicDataResources.DynamicControlParameter_DynamicDataSourceControlCannotBeUsedAsParent, ControlId)); } string columnName = Name; MetaColumn column = null; MetaTable table = MetaTableHelper.GetTableWithFullFallback(dataSource, HttpContext.Current.ToWrapper()); if (!String.IsNullOrEmpty(columnName)) { column = table.GetColumn(columnName); } else { // There was no Name attribute telling us what field to filter, but maybe // the control given us data has that info column = paramTarget.FilteredColumn; } if (column == null) { // If there is no specific column, we're setting the primary key if (paramTarget.Table != table) { throw new Exception(String.Format(CultureInfo.CurrentCulture, DynamicDataResources.DynamicControlParameter_InvalidPK, ControlId, paramTarget.Table, table.Name)); } return(GetPrimaryKeyControlWhereParameters(control, paramTarget)); } else if (column is MetaForeignKeyColumn) { return(GetForeignKeyControlWhereParameters(control, paramTarget, (MetaForeignKeyColumn)column)); } return(GetPropertyControlWhereParameters(control, paramTarget, column)); }