Skip to main content
You are viewing help content for a version that is no longer maintained/updated.
All docs
V21.2
  • IObjectDataSourceValidationService Interface

    Allows custom validation of the ObjectDataSource data sources before using them in the document.

    Namespace: DevExpress.Snap.Services

    Assembly: DevExpress.Snap.v21.2.Core.dll

    NuGet Package: DevExpress.Snap.Core

    Declaration

    public interface IObjectDataSourceValidationService

    Remarks

    The ObjectDataSource can cause an undesired behavior when retrieving its data. This may be unacceptable in certain situations. You can use the SnapControlOptions.DataSourceOptions option to specify whether to prohibit the ObjectDataSource data retrieval, prompt the user or silently load the data. To prompt the user, the default IObjectDataSourceValidationService implementation is called. However, you can implement your own service with a custom IObjectDataSourceValidationService.Validate method to replace the default service.

    Example

    View Example

                snapControl1.ReplaceService<IObjectDataSourceValidationService>(new MyObjectDataSourceValidationService());
    public class MyObjectDataSourceValidationService : IObjectDataSourceValidationService {
        public void Validate(IEnumerable<ObjectDataSource> dataSources) {
            // Do nothing to allow loading.
            // Clear the DataSource and DataMember properties to prohibit loading.
            foreach (ObjectDataSource ds in dataSources) {
                ds.DataSource = null;
                ds.DataMember = null;
            };
        }
    }
    
    See Also