Link to home
Start Free TrialLog in
Avatar of ParamhansDubey
ParamhansDubey

asked on

How to refresh the ASP.Net page after asynchronously updating the contents of page.


Hi Experts,

         I am working on a ASP.Net web application wherein I am calling a class method Asynchronously to get the data from data base (using AsyncCallback) on page load. after the completion of this callback method raises an event. I'm handling the event on the asp.net page wherein I'm assigning the datasource to a grid view. Everything is going good except for the page is not getting refreshed after the event is getting fired. I have checked the datasource of the grid is assigned properly but the contents are not shown on the page.

My question is what can I do to refresh the contents of the page.


Please help its Urgent

Thanks and Regards
Paramhans
Avatar of Stephan
Stephan
Flag of Netherlands image

Not sure if you mean that your data you have attached to the gridview needs to be refreshed, or the entire page.

If the first one: try GridView.DataBind();
Avatar of ParamhansDubey
ParamhansDubey

ASKER

As I mentioned I'm calling the method Asynchronously so after the event is fired and after assigning the data source to the grid and after data binding it i want to post back the page to the server so that the latest contents of the page are visible on the page. I want to refresh the entire page on that event.
This is not possible. What you are trying to do is access the browser from the server side after the Page has already loaded. This cannot be done without some client initiation.

So, the code behind model is not really suitable for your purpose. However, an ugly way to do this would to be make the class method you are calling set a flag to define when it is finished, it will have to be on a per request/ session/ or global basis whichever suits your needs. Then put your GridView in an UpdatePanel, hide a Button on the page which causes an AsyncPostback after the page loads and inside the Button_Click method, make your PostBack wait until the data is loaded then call updatePanelName.Update() and complete the postback. Also make sure you dont start loading the data again duiring the postback.
ASKER CERTIFIED SOLUTION
Avatar of raaziq
raaziq

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial