Back to Devexpress

IObjectDataSourceValidationService.Validate(IEnumerable<ObjectDataSource>) Method

officefileapi-devexpress-dot-xtraspreadsheet-dot-services-dot-iobjectdatasourcevalidationservice-dot-validate-x28-system-dot-collections-dot-generic-dot-ienumerable-devexpress-dot-dataaccess-dot-objectbinding-dot-objectdatasource-x29.md

latest4.3 KB
Original Source

IObjectDataSourceValidationService.Validate(IEnumerable<ObjectDataSource>) Method

Validates the ObjectDataSource data objects before data retrieval.

Namespace : DevExpress.XtraSpreadsheet.Services

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

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
void Validate(
    IEnumerable<ObjectDataSource> dataSources
)
vb
Sub Validate(
    dataSources As IEnumerable(Of ObjectDataSource)
)

Parameters

NameTypeDescription
dataSourcesIEnumerable<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

csharp
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;
            };
        }
    }
vb
Imports DevExpress.DataAccess.ObjectBinding
Imports DevExpress.XtraSpreadsheet.Services
            If barCheckCustomValidationService.Checked Then
                spreadsheetControl1.ReplaceService(Of IObjectDataSourceValidationService)(New MyObjectDataSourceValidationService())
            Else
                spreadsheetControl1.ReplaceService(Of IObjectDataSourceValidationService)(New ObjectDataSourceValidationService(spreadsheetControl1))
            End If
    Public Class MyObjectDataSourceValidationService
        Implements IObjectDataSourceValidationService

        Public Sub Validate(ByVal dataSources As IEnumerable(Of ObjectDataSource)) Implements IObjectDataSourceValidationService.Validate
            ' Do nothing to allow the control to load data.
            ' Clear the DataSource and DataMember properties to prohibit data loading.
            For Each ds As ObjectDataSource In dataSources
                ds.DataSource = Nothing
                ds.DataMember = Nothing
            Next ds
        End Sub
    End Class

See Also

IObjectDataSourceValidationService Interface

IObjectDataSourceValidationService Members

DevExpress.XtraSpreadsheet.Services Namespace