I have an .aspx page with a WebDataTree control, a WebHierarchicalDataSource control (configured with 2 SqlDataSource controls), and a WebUpload control.
It's a simple setup, user uploads a file, which executes some code-behind that updates the database, which should then refresh the WebDataTree. The tree is indeed initially populated with existing data. And Uploading new files should refresh that list.
The database does get updated with new file information, and If I force a page refresh the tree does get repopulated. But I'd like the WebDataTree to repopulate once a file is uploaded, which I normally do by calling the control's DataBind() on post back, in this case WedDataTree1.DataBind() during the WebUpload1_UploadFinished() event.
But this does not refresh the WebDataTree control. Am I missing something? Is this not the way to refresh the control?
Hi Dave Festa,
Thank you for posting in our forums!
The reason the WebDataTree is not refreshing is due to the WebUpload sending requests to the WebUpload's handler rather than to the page. The browser is not expecting a response from the page, and does not update anything. If you check your network traffic, you will see this.
To update the page, you will need to determine on the client side when the uploads are finished and make a request to the page to see any new data. I have attached a sample that demonstrates how this can be done. Once the files are uploaded, the client triggers a postback that updates the label.
To run this sample, you will need to import your ig_ui folder into the project. This can easily be done by opening the design surface in Visual Studio. The designer will prompt you to import the folder automatically.
If you have any further questions or concerns with this, please let me know and I will be glad to help.
Thank you for the reply.
After looking over your sample code it seems your introducing an awful lot of extra code just to generate a Postback (or partial postback in your example) when the WebUpload control already does this, I can debug and break on this server side event:
WebUpload1_UploadFinished(sender As Object, e As UploadFinishedEventArgs) Handles WebUpload1.UploadFinished
It's at this point I save the file to my database (which succeeds) and attempt to refresh the WebDataTree via DataBind() during a full postback.
Why do I need to create and then hook into the client side WebUpload1_FileUploaded event to fire a click event of an invisible button inside an update panel(which doesn't exist in my example) to generate a partial postback to update the tree/label. Why is the server side event not enough?