The Type Arguments Cannot be Inferred from the Usage

The Data Grid, ComboBox, List Box, TagBox, and ComboBox Column includes the DataAsync property. It allows you to bind the component to a strongly typed collection that is loaded asynchronously.

The following exception occurs if you declare the DataAsync function with an incorrect signature:

The type arguments for method ‘TypeInference.CreateDxDataGrid_0<T>’ cannot be inferred from the usage. Try specifying the type arguments explicitly.

To resolve the issue, ensure that the function signature meets the following requirements:

  • The type of the returned value is Task<IEnumerable<T>>.
  • The function has a parameter of the CancellationToken type.
@using System.Threading

<DxDataGrid DataAsync="@GetForecastAsync">

@code {
    public class WeatherForecast {
        // ...

    public Task<IEnumerable<WeatherForecast>> GetForecastAsync(CancellationToken ct = default) {
        // ...