IObjectDataSourceValidationService.Validate(IEnumerable<ObjectDataSource>) Method
Validates the ObjectDataSource data objects before data retrieval.
Namespace: DevExpress.XtraSpreadsheet.Services
Assembly: DevExpress.Spreadsheet.v18.2.Core.dll
Declaration
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
Note
A complete sample project is available at https://github.com/DevExpress-Examples/how-to-validate-the-objectdatasource-contained-in-the-spreadsheet-mailmerge-template-t514794
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 loading.
' Clear the DataSource and DataMember properties to prohibit loading.
For Each ds As ObjectDataSource In dataSources
ds.DataSource = Nothing
ds.DataMember = Nothing
Next ds
End Sub
End Class
See Also