Binding a List to Fluent Datagrid in Blazor

638 Views Asked by At

I am trying to bind a list I return from the database to the fluent datagrid in blazor.

Code to fetch List:

    @code {
    IList<Assessment>? assm = new List<Assessment>();
    protected override async Task OnInitializedAsync()
    {
        assm = await Assessment.GetAllAssessments();
    
    }
}

This will get me an a list of rows from the database, but I am having trouble binding the rows to the datagrid. How can you bind a list to the grid?

1

There are 1 best solutions below

0
On BEST ANSWER
<FluentDataGrid ... Items="@FilteredItems" >
  ...
</FluentDataGrid>

@code
{
   IList<Assessment> assm = new List<Assessment>(); // no '?'
   IQueryable<Assessment> FilteredItems => assm.AsQueryable();
}