Hi, I am using UltraWebGrid Version 8.2.20082.1000 on an ASP.NET 3.5 page with UpdatePanel. Grid is set to use LoadOnDemand=Xml and I have implemented the InitializeDataSource event in which the grid is DataBind.
I have a button on the page which fires a server-side event. Steps in codebehind event:
1. Create a new temporary UltraWebGrid (will be used to export grid data)
2. Copy selected rows to temp grid
3. Delete selected rows from the database
4. Delete selected rows from the DisplayLayout
5. Export the temp grid
The rows get deleted properly from the database. The selected rows are exported fine and the user gets a prompt to open/save the exported file. The problem is that the grid on the client-side does not get refreshed after the export. The rows that I deleted are still visible in the grid until the next postback. I tried to call DataBind on the grid before and after the export but it did not help.
Thanks!
Hello,
I actualy have the exact same problem with my grid only I am not creating a temporary grid and I am exporting to Excel not pdf.
I am using a checkbox column to select the rows that i want to delete from the database where the data resides. Once the user has selected all of the rows they wish to remove, the code steps through the grid and adds all of the rows that are checked to a list. That list is then passed as a parameter to a stored procedure which then updates the database. At this point, I have the same problem as you, since my grid is inside an update panel, the rows that were deleted are still on the page even after the database has been updated. I have to totally navigate away from the page (to another page in the application) and then return to the page in order to cause a postback and therefore see the updated grid without the rows that I deleted showing up...
I was just wondering if you had come across a solution yet or not...
mbradham12 said: Hello, I actualy have the exact same problem with my grid only I am not creating a temporary grid and I am exporting to Excel not pdf. I am using a checkbox column to select the rows that i want to delete from the database where the data resides. Once the user has selected all of the rows they wish to remove, the code steps through the grid and adds all of the rows that are checked to a list. That list is then passed as a parameter to a stored procedure which then updates the database. At this point, I have the same problem as you, since my grid is inside an update panel, the rows that were deleted are still on the page even after the database has been updated. I have to totally navigate away from the page (to another page in the application) and then return to the page in order to cause a postback and therefore see the updated grid without the rows that I deleted showing up... I was just wondering if you had come across a solution yet or not... Thanks!
Hello, During the async postback I had to manually remove the deleted rows from the DisplayLayout of the grid. Please refer to Rumen Stankov's solution to trigger the download after the first async postback is finished.
Maybe it is possible to first update the grid (delete rows, rebind and show the updated gri) and then automatically start the export with javascript. You can hook javascript to an UpdatePanel endRequest event with this BLOCKED SCRIPT
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(RunThisAfterEachAsyncPostback);
and then in the event handler you can simulate click on the Export to Excel/PDF button withfunction RunThisAfterAsyncPostback(){ document.getElementById("<%= ExportButton.ClientID %>").click();
}</script>
Will this work in your scenario?