I am working with WebHierarchicalDataGrid and I made some cells editable, but when I change some of the cells I need to press a button to save the changes, but I am not able to get the changes, I still got the old values before the changes done in the grid.
Hello Hossam,
In order to investigate your issue correctly I would need some more information regarding your scenario. For example, have you enabled the AutoCRUD property of the grid or are you using Manual CRUD?
When AutoCRUD is enabled, the grid attempts to automatically update the datasource the grid is bound to, this is also the default behavior of the grid.
If you disable it, then you are expected to maintain updates manually through code, you would need to handle the RowUpdating, RowDeleting, and RowAdding events on the server to add the updated data to your data source. You could then handle a later page lifecycle event, such as PreRender event of the grid, to store your data in your database before rendering the grid.
Below you can find a blog post that demonstrates how Manual CRUD could be implemented on the WebHierarchicalDataGrid and contains a small sample application:
https://www.infragistics.com/community/blogs/b/radoslav_minchev/posts/manual-crud-webhierarchicaldatagrid
If you are using Manual CRUD and the data is not refreshing even after you have handled the changes in their corresponding events, then you could use the RequestFullAsyncRender method to refresh the grid in order to reflect your CRUD changes. It could be done with the following code:
this.WebHierarchicalDataGrid1.GridView.RequestFullAsyncRender();
Additionally, if you would like to have an unlimited number of rows that can be modified without calling the server and then being able to undo or clear any of them, then you can enable Batch updating. With it all changes – adding, updating, deleting rows are kept on the client and are send to the server on the first triggered postback. Below you can find a sample that uses Batch Updating:
https://www.infragistics.com/samples/aspnet/hierarchical-data-grid/batch-updating
Additionally, it would be great if you could provide some code snippets for your grid for both markup and code behind so I can get a better understanding of your issue. It would be ideal if you could provide a small isolated sample that demonstrates the issue.
Having a working sample on my side, which I can debug, is going to be very helpful in finding the root cause of this behavior.
Thank you for your cooperation.
Looking forward to hearing from you.
Regards, Ivan Kitanov
Thank you for your answer! You gave me good information, however I need to know more about BatchUpdating.
I added this line (whdg.GridView.Behaviors.EditingCore.BatchUpdating = True) in he below code
And I need to know how to get GetBatchUpdates?
In order to ensure that your issue is addressed correctly, I will need some additional information regarding your scenario. Can you please answer the following questions:
Could you elaborate more on what do you mean by GetBatchUpdates?
Do you have AutoCRUD enabled or not?
Are the changes getting reflected once you press the button to save them or are you still getting the old values?
How are you binding the data to the grid?
Could you explain your scenario in further detail, could you provide steps or a small sample to reproduce your issue?
I also recommend you reviewing the following sample, it demonstrates how a grid could be bound to ObjectDataSource by using WebHierarchicalDataSource, it also demonstrates the use of BatchUpdating with AutoCRUD enabled. The changes are handled on the client and after the user has pressed the save button the changes are automatically processed and saved.
Let me clarify more about my issue,
We have WebHierarchicalDataGrid that we need to make it editable for editing some cells and then we disabled a specific column, so the below code is written after binding the datasource in order to enable the edit and disable a column. After that we need to save the edited cells into the database after pressings the save button but the issue is that I am still getting the old cell values not the edited one, so I tried to solve the issue by adding the marked line in red in the below screenshot to enable the batch updating, but it didn't solve my problem actually.
I am trying to get the updated cell values in the row updating event as shown in the below screenshot but the values retrieved are the old values and not the new one. On the market lines in the below screenshot you can see how I am getting the values of the cells that should be updated.
Actually I am not sure wither we are using the autoCRUD or manualCRUD as we didn't set this. You see the WebHierarchicalDataGrid in the aspx below.
The last thing I want you to know that the application is webforms and the backend is Visual Basic. The infragistics version is "Infragistics45.Web.v22.1, Version=22.1.20221.11"
Thank you
If you are not setting the property, then it means that you are using AutoCRUD, which is the default behavior.
The reason why you are receiving the old values is that the RowUpdating is fired every time a row is about to be updated, which makes accessing the row and obtaining the values return the old values. Instead, you could access the new values similarly to the code below:
updatedRow.sProdLine = e.Values[“product_line”].Value;
Please test this in your application and let me know if you have any questions or concerns.