corelibraries-devexpress-dot-dataaccess-dot-json-dot-jsondatasource-530aaaae.md
Occurs when an attempt to fill the data source fails.
Namespace : DevExpress.DataAccess.Json
Assembly : DevExpress.DataAccess.v25.2.dll
NuGet Package : DevExpress.DataAccess
public event DataSourceFillErrorEventHandler FillError
Public Event FillError As DataSourceFillErrorEventHandler
The FillError event's data class is DataSourceFillErrorEventArgs. The following properties provide information specific to this event:
| Property | Description |
|---|---|
| ConnectionName | Specifies the name of the JSON data source connection that was used when the FillError event occurred. |
| Exception | Gets the exception that caused the FillError event. |
| Handled | Gets or sets whether the FillError event has been handled. |
This event occurs when a call to the Fill() method fails to populate the data source with data. Handle this event to process the following exceptions:
Use the following properties to retrieve the exception details:
The JsonDataSourceException exception occurs instead of the WebException , IOException , and parse errors. Catch this exception as an alternative to the FillError event.
try {
dataSource.Fill()
}
catch(JsonDataSourceException e) {
//do something
}
Try
dataSource.Fill()
Catch e As JsonDataSourceException
'do something
End Try
The code sample below creates a new data source, handles the FillError event to to process exceptions, and tries to populate the data source with data.
using DevExpress.DataAccess;
using DevExpress.DataAccess.Json;
// ...
// Create a new JSON source.
var jsonSource = new UriJsonSource() {
Uri = new Uri(@"https://invalid.json")
};
// Assign the JSON source to the data source.
var datasource = new JsonDataSource() {
JsonSource = jsonSource
};
datasource.FillError += (s, e) => {
e.Handled = true;
// Add code that handles the data source fill error here.
};
Imports DevExpress.DataAccess
Imports DevExpress.DataAccess.Json
' ...
' Create a new JSON source.
Dim jsonSource = New UriJsonSource() With {.Uri = New Uri("https://invalid.json")}
' Assign the JSON source to the data source.
Dim datasource = New JsonDataSource() With {.JsonSource = jsonSource}
AddHandler datasource.FillError, Sub(s, e)
e.Handled = True
' Add code that handles the data source fill error here.
End Sub
See Also