Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

IObjectDataSourceValidationService.Validate(IEnumerable<ObjectDataSource>) Method

Validates the ObjectDataSource data objects before data retrieval.

Namespace: DevExpress.XtraSpreadsheet.Services

Assembly: DevExpress.Spreadsheet.v24.2.Core.dll

NuGet Package: DevExpress.Spreadsheet.Core

#Declaration

void Validate(
    IEnumerable<ObjectDataSource> dataSources
)

#Parameters

Name Type Description
dataSources IEnumerable<ObjectDataSource>

An IEnumerable<T><ObjectDataSource,> collection to validate.

#Remarks

To prevent a data object in a collection from executing its data retrieval method, set its ObjectDataSource.DataSource and ObjectDataSource.DataMember properties to null.

#Example

using DevExpress.DataAccess.ObjectBinding;
using DevExpress.XtraSpreadsheet.Services;
            if (barCheckCustomValidationService.Checked) {
                spreadsheetControl1.ReplaceService<IObjectDataSourceValidationService>(new MyObjectDataSourceValidationService());
            }
            else {
                spreadsheetControl1.ReplaceService<IObjectDataSourceValidationService>(new ObjectDataSourceValidationService(spreadsheetControl1));
            }
    public class MyObjectDataSourceValidationService : IObjectDataSourceValidationService {
        public void Validate(IEnumerable<ObjectDataSource> dataSources) {
            // Do nothing to allow the control to load data.
            // Clear the DataSource and DataMember properties to prohibit data loading.
            foreach (ObjectDataSource ds in dataSources) {
                ds.DataSource = null;
                ds.DataMember = null;
            };
        }
    }
See Also