How to refresh parent form List tied to a DataGrid from Dialog

My project has a sales form which spawns a child dialog that will contain / allow the user to enter new lines on an order. I have tried adding the parent form to the scope of the project in Program.cs so that I can access it from other forms and update values. I injected the parent class into the dialog page in hopes that I could update the properties in the parent class but no luck. Currently I have a AddOrderLines method on the dialog that gets the parent forms OrderLines List and then adds to it. After doing to it calls the refresh grid method in the paretnfor (Sales) class. When I clsoe the dialog OrderLines doesnt contain any of the information I passed.



You can see that the button on Sales2 is initiating everything and the intent is that the grid behind the dialog updates with the new info even if the dialog is still showing. Any help would be greatly appreciated!

I have also tried to pass the entire reference to the dataGrid, tried AsyncInvoke, followed a previous ticket on the forum but no luck. Send help

Hi @Ian_Morris,

Injecting a component won't work - it won't be the same instance as the parent itself. You could use a service instead - the parent could subscribe to a service event and the dialog could trigger the event.

@korchev bro you need a raise! Ok, I have one service setup already, so I'll try that route. Do you have any live examples of this by chance?

No, we don't have a live example of this. You can check my reply in this thread for some inspiration: DataGrid row background color when editing - #2 by korchev (it serves a different purpose but the intent is similar - to refresh a grid when a service event is triggered).

1 Like

@korchev I converted everything over to a service, and the service is receiving the new line, but the component is failing to refresh until I manually refresh it, and then I see the added line. Here is what im doing:


You haven't provided code which handles the Change event of your service.

@korchev sorry about that, here is the code.

Still not that. Your component needs to handle the OnChange event and refresh itself. Check the thread I've linked.

@korchev figured it out. Had to add the refresh back to the component after state update is declared. Works great now! Radzen is great