Back to Devexpress

JsonDataSource.Fill() Method

corelibraries-devexpress-dot-dataaccess-dot-json-dot-jsondatasource-a88a2ebd.md

latest6.7 KB
Original Source

JsonDataSource.Fill() Method

Populates the JsonDataSource object with JSON data.

Namespace : DevExpress.DataAccess.Json

Assembly : DevExpress.DataAccess.v25.2.dll

NuGet Package : DevExpress.DataAccess

Declaration

csharp
public void Fill()
vb
Public Sub Fill

Remarks

Use the Fill method to populate the JsonDataSource with data.

If you did not define the data source schema, the data source is populated with all data available from the source.

The JsonDataSourceException exception occurs if the Fill method failed to populate the data source. Catch this exception or handle the FillError event to ensure that the Fill method has completed successfully.

Example

The code sample below creates a JSON data source and populates it with data from the endpoint.

csharp
using DevExpress.DataAccess.Json;
// ...
// Create a new JSON data source and populate it with data.
var jsonDataSource = new JsonDataSource();
jsonDataSource.JsonSource = new UriJsonSource() {
    Uri = new Uri(@"https://raw.githubusercontent.com/DevExpress-Examples/DataSources/master/JSON/customers.json")
};
jsonDataSource.Fill();
vb
Imports DevExpress.DataAccess.Json
' ...
' Create a new JSON data source and populate it with data.
Dim jsonDataSource = New JsonDataSource()
jsonDataSource.JsonSource = New UriJsonSource() With {.Uri = New Uri("https://raw.githubusercontent.com/DevExpress-Examples/DataSources/master/JSON/customers.json")}
jsonDataSource.Fill()

The following code snippets (auto-collected from DevExpress Examples) contain references to the Fill() method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

winforms-dashboard-json-data-source/CS/DashboardJsonExample/Form1.cs#L52

csharp
jsonDataSource.RootElement = "Customers";
jsonDataSource.Fill();
return jsonDataSource;

reporting-winforms-provide-authentication-to-access-json-data/CS/Form1.cs#L26

csharp
// Retrieve data to populate the Report Designer's Field List
jsonDataSource.Fill();

reporting-winforms-create-report-bound-to-json-data-source/CS/Form1.cs#L102

csharp
// Populate the data source with data.
jsonDataSource.Fill();
return jsonDataSource;

data-access-library-create-data-sources-at-runtime/CS/JsonDataSourceSnippets/Code.cs#L16

csharp
jsonDataSource.JsonSource = new DevExpress.DataAccess.Json.UriJsonSource(sourceUri);
    jsonDataSource.Fill();
}

reporting-web-forms-report-designer-add-data-sources/CS/WebApplication1/Default.aspx.cs#L31

csharp
jsonDataSource.JsonSource = new DevExpress.DataAccess.Json.UriJsonSource(uri);
jsonDataSource.Fill();
return jsonDataSource;

winforms-dashboard-json-data-source/VB/DashboardJsonExample/Form1.vb#L49

vb
jsonDataSource.RootElement = "Customers"
jsonDataSource.Fill()
Return jsonDataSource

reporting-winforms-provide-authentication-to-access-json-data/VB/Form1.vb#L27

vb
' Retrieve data to populate the Report Designer's Field List
jsonDataSource.Fill()

reporting-winforms-create-report-bound-to-json-data-source/VB/Form1.vb#L89

vb
' Populate the data source with data.
jsonDataSource.Fill()
Return jsonDataSource

data-access-library-create-data-sources-at-runtime/VB/JsonDataSourceSnippets/Code.vb#L13

vb
jsonDataSource.JsonSource = New DevExpress.DataAccess.Json.UriJsonSource(sourceUri)
    jsonDataSource.Fill()
End Sub

reporting-web-forms-report-designer-add-data-sources/VB/WebApplication1/Default.aspx.vb#L31

vb
jsonDataSource.JsonSource = New DevExpress.DataAccess.Json.UriJsonSource(sourceUri)
jsonDataSource.Fill()
Return jsonDataSource

See Also

Bind a Report to JSON Data (Runtime Sample)

JsonDataSource Class

JsonDataSource Members

DevExpress.DataAccess.Json Namespace