private DataSourceView ConnectToDataSourceView() { if (!this._currentViewValid || base.DesignMode) { if ((this._currentView != null) && this._currentViewIsFromDataSourceID) { this._currentView.DataSourceViewChanged -= new EventHandler(this.OnDataSourceViewChanged); } this._currentDataSource = this.GetDataSource(); string dataMember = this.DataMember; if (this._currentDataSource == null) { this._currentDataSource = new ReadOnlyDataSource(this.DataSource, dataMember); } else if (this.DataSource != null) { throw new InvalidOperationException(System.Web.SR.GetString("DataControl_MultipleDataSources", new object[] { this.ID })); } this._currentDataSourceValid = true; DataSourceView view = this._currentDataSource.GetView(dataMember); if (view == null) { throw new InvalidOperationException(System.Web.SR.GetString("DataControl_ViewNotFound", new object[] { this.ID })); } this._currentViewIsFromDataSourceID = base.IsBoundUsingDataSourceID; this._currentView = view; if ((this._currentView != null) && this._currentViewIsFromDataSourceID) { this._currentView.DataSourceViewChanged += new EventHandler(this.OnDataSourceViewChanged); } this._currentViewValid = true; } return this._currentView; }
public override object GetValue(object component) { IDataSource dataSource = component as IDataSource; if (dataSource == null) { return(null); } DataSourceView view = dataSource.GetView(Name); return(view.ExecuteSelect(DataSourceSelectArguments.Empty)); }
public void RaiseUnsupportedCapabilitiesError(DataSourceView view) { DataSourceCapabilities capabilities = this._requestedCapabilities & ~this._supportedCapabilities; if ((capabilities & DataSourceCapabilities.Sort) != DataSourceCapabilities.None) { view.RaiseUnsupportedCapabilityError(DataSourceCapabilities.Sort); } if ((capabilities & DataSourceCapabilities.Page) != DataSourceCapabilities.None) { view.RaiseUnsupportedCapabilityError(DataSourceCapabilities.Page); } if ((capabilities & DataSourceCapabilities.RetrieveTotalRowCount) != DataSourceCapabilities.None) { view.RaiseUnsupportedCapabilityError(DataSourceCapabilities.RetrieveTotalRowCount); } }
private DataSourceView ConnectToDataSourceView() { if (!this._currentViewValid || base.DesignMode) { if ((this._currentView != null) && this._currentViewIsFromDataSourceID) { this._currentView.DataSourceViewChanged -= new EventHandler(this.OnDataSourceViewChanged); } IDataSource source = null; string dataSourceID = this.DataSourceID; if (dataSourceID.Length != 0) { Control control = DataBoundControlHelper.FindControl(this, dataSourceID); if (control == null) { throw new HttpException(System.Web.SR.GetString("DataControl_DataSourceDoesntExist", new object[] { this.ID, dataSourceID })); } source = control as IDataSource; if (source == null) { throw new HttpException(System.Web.SR.GetString("DataControl_DataSourceIDMustBeDataControl", new object[] { this.ID, dataSourceID })); } } if (source == null) { source = new ReadOnlyDataSource(this.DataSource, this.DataMember); } else if (this.DataSource != null) { throw new InvalidOperationException(System.Web.SR.GetString("DataControl_MultipleDataSources", new object[] { this.ID })); } DataSourceView view = source.GetView(this.DataMember); if (view == null) { throw new InvalidOperationException(System.Web.SR.GetString("DataControl_ViewNotFound", new object[] { this.ID })); } this._currentViewIsFromDataSourceID = this.IsBoundUsingDataSourceID; this._currentView = view; if ((this._currentView != null) && this._currentViewIsFromDataSourceID) { this._currentView.DataSourceViewChanged += new EventHandler(this.OnDataSourceViewChanged); } this._currentViewValid = true; } return this._currentView; }
/// <summary> /// return a strongly typed view for the current data source control /// </summary> /// <param name="viewName"></param> /// <returns></returns> protected override DataSourceView GetView(string viewName) { // only retrieve a view if a membership provider can be found if (_view == null) { try { if (ViewName == "FBAUsersView") _view = new FBAUsersView(this, viewName); else if (ViewName == "FBARolesView") _view = new FBARolesView(this, viewName); } catch (Exception ex) { Utils.LogError(ex, true); } } return _view; }
// The RaiseUnsupportedCapabilitiesError method is used by data-bound controls // to compare additional requested capabilities represented by the properties // of the DataSourceSelectArguments class, such as the ability to sort or page // through a result set, with the capabilities supported by the data source view. // The view calls its own RaiseUnsupportedCapabilityError method for each possible // capability defined in the DataSourceCapabilities enumeration. public void RaiseUnsupportedCapabilitiesError(DataSourceView view) { DataSourceCapabilities requestedCaps = RequestedCapabilities; DataSourceCapabilities notSupportedCaps = (requestedCaps ^ dsc) & requestedCaps; if (notSupportedCaps == DataSourceCapabilities.None) { return; } if ((notSupportedCaps & DataSourceCapabilities.RetrieveTotalRowCount) > 0) { notSupportedCaps = DataSourceCapabilities.RetrieveTotalRowCount; } else if ((notSupportedCaps & DataSourceCapabilities.Page) > 0) { notSupportedCaps = DataSourceCapabilities.Page; } view.RaiseUnsupportedCapabilityError(notSupportedCaps); }
/// <devdoc> /// Select implementations would call this method to raise errors on unsupported capabilities. /// </devdoc> public void RaiseUnsupportedCapabilitiesError(DataSourceView view) { DataSourceCapabilities unsupportedCapabilities; unsupportedCapabilities = _requestedCapabilities & ~_supportedCapabilities; if ((unsupportedCapabilities & DataSourceCapabilities.Sort) != 0) { view.RaiseUnsupportedCapabilityError(DataSourceCapabilities.Sort); } if ((unsupportedCapabilities & DataSourceCapabilities.Page) != 0) { view.RaiseUnsupportedCapabilityError(DataSourceCapabilities.Page); } if ((unsupportedCapabilities & DataSourceCapabilities.RetrieveTotalRowCount) != 0) { view.RaiseUnsupportedCapabilityError(DataSourceCapabilities.RetrieveTotalRowCount); } Debug.Assert(unsupportedCapabilities == 0, "unknown capability not supported"); }
private DataSourceView ConnectToDataSourceView() { // If the current view is correct, there is no need to reconnect if (_currentViewValid && !DesignMode) return _currentView; // Disconnect from old view, if necessary if ((_currentView != null) && (_currentViewIsFromDataSourceID)) { // We only care about this event if we are bound through the DataSourceID property _currentView.DataSourceViewChanged -= new EventHandler(OnDataSourceViewChanged); } // Connect to new view IDataSource ds = null; string dataSourceID = DataSourceID; if (!string.IsNullOrEmpty(dataSourceID)) { // Try to find a DataSource control with the ID specified in DataSourceID Control control = NamingContainer.FindControl(dataSourceID); if (control == null) throw new HttpException(String.Format(CultureInfo.CurrentCulture, "DataSource '{1}' for control '{0}' doesn't exist", ID, dataSourceID)); ds = control as IDataSource; if (ds == null) throw new HttpException(String.Format(CultureInfo.CurrentCulture, "'{1}' is not a data source for control '{0}'.", ID, dataSourceID)); } if (ds == null) { // DataSource control was not found, construct a temporary data source to wrap the data return null; } else { // Ensure that both DataSourceID as well as DataSource are not set at the same time if (DataSource != null) throw new InvalidOperationException("DataSourceID and DataSource can't be set at the same time."); } // IDataSource was found, extract the appropriate view and return it DataSourceView newView = ds.GetView(DataMember); if (newView == null) throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, "DataSourceView not found for control '{0}'", ID)); _currentViewIsFromDataSourceID = IsBoundUsingDataSourceID; _currentView = newView; // If we're bound through the DataSourceID proeprty, then we care about this event if ((_currentView != null) && (_currentViewIsFromDataSourceID)) _currentView.DataSourceViewChanged += new EventHandler(OnDataSourceViewChanged); _currentViewValid = true; return _currentView; }
public ActionDataSourceView(ActionDataSource source, string viewName, DataSourceView underlyingDataSourceView) : base(source, viewName) { UnderlyingView = underlyingDataSourceView; ActionDS = source; }
void UpdateViewData() { DataSourceView view = this.InternalGetData(); if (view == currentView) { return; } if (currentView != null) { currentView.DataSourceViewChanged -= OnDataSourceViewChanged; } currentView = view; if (view != null) { view.DataSourceViewChanged += OnDataSourceViewChanged; } }
public SessionDataSourceView(SqlDataSource owner, string name, HttpContext context, DataSourceView originalView, HttpSessionState session) : base(owner, name, context) { this.owner = owner as SessionDataSource; this.originalView = originalView; this.session = session; this.context = context; }
public void RaiseUnsupportedCapabilitiesError (DataSourceView view) { view.RaiseUnsupportedCapabilityError (this.dsc); }
public void RaiseUnsupportedCapabilitiesError (DataSourceView view) { Contract.Requires (view != null); }
/// <devdoc> /// Connects this data bound control to the appropriate DataSourceView /// and hooks up the appropriate event listener for the /// DataSourceViewChanged event. The return value is the new view (if /// any) that was connected to. An exception is thrown if there is /// a problem finding the requested view or data source. /// </devdoc> private DataSourceView ConnectToDataSourceView() { if (_currentViewValid && !DesignMode) { // If the current view is correct, there is no need to reconnect return _currentView; } // Disconnect from old view, if necessary if ((_currentView != null) && (_currentViewIsFromDataSourceID)) { // We only care about this event if we are bound through the DataSourceID property _currentView.DataSourceViewChanged -= new EventHandler(OnDataSourceViewChanged); } // Connect to new view IDataSource ds = null; if (!DesignMode && IsUsingModelBinders) { if (DataSourceID.Length != 0 || DataSource != null) { throw new InvalidOperationException(SR.GetString(SR.DataControl_ItemType_MultipleDataSources, ID)); } //Let the developer choose a custom ModelDataSource. CreatingModelDataSourceEventArgs e = new CreatingModelDataSourceEventArgs(); OnCreatingModelDataSource(e); if (e.ModelDataSource != null) { ModelDataSource = e.ModelDataSource; } //Update the properties of ModelDataSource so that it's ready for data-binding. UpdateModelDataSourceProperties(ModelDataSource); //Add the CallingDataMethodsEvent CallingDataMethodsEventHandler handler = Events[EventCallingDataMethods] as CallingDataMethodsEventHandler; if (handler != null) { ModelDataSource.CallingDataMethods += handler; } ds = ModelDataSource; } else { string dataSourceID = DataSourceID; if (dataSourceID.Length != 0) { // Try to find a DataSource control with the ID specified in DataSourceID Control control = DataBoundControlHelper.FindControl(this, dataSourceID); if (control == null) { throw new HttpException(SR.GetString(SR.DataControl_DataSourceDoesntExist, ID, dataSourceID)); } ds = control as IDataSource; if (ds == null) { throw new HttpException(SR.GetString(SR.DataControl_DataSourceIDMustBeDataControl, ID, dataSourceID)); } } } if (ds == null) { // DataSource control was not found, construct a temporary data source to wrap the data ds = new ReadOnlyDataSource(DataSource, DataMember); } else { // Ensure that both DataSourceID as well as DataSource are not set at the same time if (DataSource != null) { throw new InvalidOperationException(SR.GetString(SR.DataControl_MultipleDataSources, ID)); } } // IDataSource was found, extract the appropriate view and return it DataSourceView newView = ds.GetView(DataMember); if (newView == null) { throw new InvalidOperationException(SR.GetString(SR.DataControl_ViewNotFound, ID)); } _currentViewIsFromDataSourceID = IsDataBindingAutomatic; _currentView = newView; if ((_currentView != null) && (_currentViewIsFromDataSourceID)) { // We only care about this event if we are bound through the DataSourceID property _currentView.DataSourceViewChanged += new EventHandler(OnDataSourceViewChanged); } _currentViewValid = true; return _currentView; }
public void RaiseUnsupportedCapabilitiesError(DataSourceView view) { }
// The RaiseUnsupportedCapabilitiesError method is used by data-bound controls // to compare additional requested capabilities represented by the properties // of the DataSourceSelectArguments class, such as the ability to sort or page // through a result set, with the capabilities supported by the data source view. // The view calls its own RaiseUnsupportedCapabilityError method for each possible // capability defined in the DataSourceCapabilities enumeration. public void RaiseUnsupportedCapabilitiesError (DataSourceView view) { DataSourceCapabilities requestedCaps = RequestedCapabilities; DataSourceCapabilities notSupportedCaps = (requestedCaps ^ dsc) & requestedCaps; if (notSupportedCaps == DataSourceCapabilities.None) return; if ((notSupportedCaps & DataSourceCapabilities.RetrieveTotalRowCount) > 0) notSupportedCaps = DataSourceCapabilities.RetrieveTotalRowCount; else if ((notSupportedCaps & DataSourceCapabilities.Page) > 0) notSupportedCaps = DataSourceCapabilities.Page; view.RaiseUnsupportedCapabilityError (notSupportedCaps); }
public void RaiseUnsupportedCapabilitiesError(DataSourceView view) { Contract.Requires(view != null); }
/// <devdoc> /// Connects this data bound control to the appropriate DataSourceView /// and hooks up the appropriate event listener for the /// DataSourceViewChanged event. The return value is the new view (if /// any) that was connected to. An exception is thrown if there is /// a problem finding the requested view or data source. /// </devdoc> private DataSourceView ConnectToDataSourceView() { if (_currentViewValid && !DesignMode) { // If the current view is correct, there is no need to reconnect return _currentView; } // Disconnect from old view, if necessary if ((_currentView != null) && (_currentViewIsFromDataSourceID)) { // We only care about this event if we are bound through the DataSourceID property _currentView.DataSourceViewChanged -= new EventHandler(OnDataSourceViewChanged); } // Connect to new view IDataSource ds = null; string dataSourceID = DataSourceID; if (dataSourceID.Length != 0) { // Try to find a DataSource control with the ID specified in DataSourceID Control control = DataBoundControlHelper.FindControl(this, dataSourceID); if (control == null) { throw new HttpException(SR.GetString(SR.DataControl_DataSourceDoesntExist, ID, dataSourceID)); } ds = control as IDataSource; if (ds == null) { throw new HttpException(SR.GetString(SR.DataControl_DataSourceIDMustBeDataControl, ID, dataSourceID)); } } if (ds == null) { // DataSource control was not found, construct a temporary data source to wrap the data ds = new ReadOnlyDataSource(DataSource, DataMember); } else { // Ensure that both DataSourceID as well as DataSource are not set at the same time if (DataSource != null) { throw new InvalidOperationException(SR.GetString(SR.DataControl_MultipleDataSources, ID)); } } // IDataSource was found, extract the appropriate view and return it DataSourceView newView = ds.GetView(DataMember); if (newView == null) { throw new InvalidOperationException(SR.GetString(SR.DataControl_ViewNotFound, ID)); } _currentViewIsFromDataSourceID = IsBoundUsingDataSourceID; _currentView = newView; if ((_currentView != null) && (_currentViewIsFromDataSourceID)) { // We only care about this event if we are bound through the DataSourceID property _currentView.DataSourceViewChanged += new EventHandler(OnDataSourceViewChanged); } _currentViewValid = true; return _currentView; }