Search code examples
c#datagridblazorfluent-uiquickgrid

Binding a List to Fluent Datagrid in Blazor


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?


Solution

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