Radzen Grid reload not working

Dear guys,

i am working with Grids. I have just a problem with "reloading" the grid after deleting one row. TableGrid.Reload() is just not working :frowning:

<RadzenGrid @ref="TableGrid" .....................

editing and saving are working fine!

What's the type of the collection bound to the DataGrid?

I hope you can decrypt it :slight_smile:

@if (Table == null)


switch (EditTable)
        <h1 class="text-danger">Error</h1>
        <h2 class="text-danger">No Permission</h2>
    case 1:
        <RadzenGrid @ref="TableGrid" AllowFiltering="true" FilterCaseSensitivity="FilterCaseSensitivity.CaseInsensitive" AllowPaging="true" PageSize="12" AllowSorting="true" Data="@TableData" Value="TableValue" TItem="Table">
                <RadzenGridColumn TItem="Table" Property="as_req__priority" Title="Priority" Width="80px">
                    <EditTemplate Context="Priority">
                        <RadzenDropDown @bind-Value="TableValue.as_req__priority" TValue="int" Data="@TableData.Select(a=>a.as_req__priority).Append(10).Append(100).Distinct()" Style="margin-bottom: auto;width:100%" />

    List<Table> Table;

Table is created from EFCore

You are using ToList() somewhere? Usually it is DbSet<>.

Yes exactly!

Dependency injection with a service to get the data

TableData = await service.Get();


public async Task<List<Table'>> Get()

        return await _DBContext.Table.ToListAsync();

Table created with dbset

public class DBContext: DbContext
public DBContext(DbContextOptions options) : base(options)
{ }

    public DbSet<Table> Table { get; set; }


You may need to remove ToList() call and work directly with the DbSet.

If you’re using List<> you need additionally delete list row. List.Remove()

1 Like

Thank you !! Now it is working.

Hi @enchev

If I remove the ToList() from the call, I will have an "invalid cast" error.
From the demo code:

@code {
    RadzenDataGrid<Order> ordersGrid;
    IList<Order> orders;
    IEnumerable<Customer> customers;
    IEnumerable<Employee> employees;

protected override void OnInitialized()
       // For production
       orders = dbContext.Orders.Include("Customer").Include("Employee"); // ← invalid cast from DbSet<Order> to Generic.List<Order>

You cannot assign IEnumerable to IList, you should change the type of the orders field if you do not want to call ToList()

1 Like