DataGrid drop down data grid column does not refresh after update?


I am updating a data grid, all of the fields except drop-down data grid column successfully display the updated data on the grid. Can you tell me what am I doing wrong?

<RadzenDataGridColumn TItem="OrderDetail" Property="Vendor.Name" Title="Vendor" Width="200px" OrderIndex="4">
                                <EditTemplate Context="orderDetail">
                                    <RadzenDropDownDataGrid TValue="int" AllowFiltering="true" AllowClear="true" FilterCaseSensitivity="FilterCaseSensitivity.CaseInsensitive" FilterOperator="StringFilterOperator.Contains"
                                                            Data=@_vendors Count="5" TextProperty="Name" ValueProperty="Id"
                                                            Class="w-100" @bind-Value="orderDetail.VendorId" Name="vendor" id="vendor" />
                                    <RadzenNumericRangeValidator Component="vendor" Min="1" Text="Vendor is Required!" Popup=true Style="position: absolute; z-index: 9999;" />

Here is the method:

private async Task OnUpdateRowDetail(OrderDetail orderDetail)
        if (orderDetail == _detailToInsert)
            _detailToInsert = null;
        if (orderDetail != null)
            await EditOrderDetailUseCase.ExecuteAsync(orderDetail);

Here is the repo (called by ExecuteAsync)

public async Task UpdateOrderDetailAsync(OrderDetail orderDetail)
            await using var ctx = await _db.CreateDbContextAsync();
            var detail = await ctx.OrdersDetail.FindAsync(orderDetail.Id);
            if (detail != null)
                detail.Quantity = orderDetail.Quantity;
                detail.CostRatio = orderDetail.CostRatio;
                detail.Description = orderDetail.Description;
                detail.ProductCode = orderDetail.ProductCode;
                detail.ProductName = orderDetail.ProductName;
                detail.BuyUnitPrice = orderDetail.BuyUnitPrice;
                detail.ShippingNumber = orderDetail.ShippingNumber;
                detail.Status = orderDetail.Status;
                detail.TotalBuyPrice = orderDetail.BuyUnitPrice * orderDetail.Quantity;
                detail.TotalSellPrice = orderDetail.Quantity * orderDetail.SellUnitPrice;
                detail.SellUnitPrice = orderDetail.SellUnitPrice;
                detail.UnitCost = (orderDetail.BuyUnitPrice * (orderDetail.CostRatio / 100)) + orderDetail.BuyUnitPrice;
                detail.TotalUnitCost = orderDetail.UnitCost * orderDetail.Quantity;
                detail.Currency = orderDetail.Currency;
                detail.CustomerOrderNumber = orderDetail.CustomerOrderNumber;
                detail.CustomerStockCode = orderDetail.CustomerStockCode;
                detail.OrderId = orderDetail.OrderId;
                detail.VendorId = orderDetail.VendorId;
                detail.TrackingNumber = orderDetail.TrackingNumber;
                detail.Warehouse = orderDetail.Warehouse;
                detail.PaymentStatus = orderDetail.PaymentStatus;
                if (detail.Status == "Completed")
                    detail.CompletionDateTime = DateTime.Now.Date;
                    detail.CompletionDateTime = null;

                await ctx.SaveChangesAsync();

In the DB, this vendor id column is updated. All other columns on the data grid are displaying updated records but what is missing in the vendor id?

Thank you.

Not sure why you have this code (manually setting properties) for this update however in my opinion you need just ctx.OrdersDetail.Update(orderDetail) since @bind-Value already will set respective property value.

@enchev thank you for your reply. The problem is why the updated vendor is not displayed on the grid. Other updated data appears immediately on the grid.