About re-rendering DataGrid

Hello everyone.
This is a very rudimentary question, but please give me some advice.

If I have created data to be displayed in the DataGrid other than OnInitialized, how can I reflect this data in the DataGrid?

I tried StateHasChanged, but the whole page is re-rendered.
Is there a way to re-render only the DataGrid?

Hi @tomo_Big,

You can call Reload() for the DataGrid.

Thank you very much.
I tried it immediately, but it doesn't seem to work.

For some reason, I'm creating a List <> to display in the DataGrid in OnAfterRender ().

Immediately after creating List <>, reload () is called, but the state of DataGrid does not change ...

Can reload () be used in OnAfterRender?
Am I fundamentally misunderstanding ...?

Unfortunately I’m not sure why Reload() it’s not working for you. Check if new data is assigned to Data property - Reload() will rerender the grid using the collection assigned to Data.

I think OnAfterRender is too late to trigger updates unless StateHasChanged is called explicitly. However it should trigger another OnAfterRender and may lead to an endless loop. You should better use a different lifecycle method such as OnInitialized.