Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Friends,
On a button click event, I am calling File save dialogue box.
After saving the file, I want to refresh the radgrid.
When I try with RadGrid.Rebind() method, it calls the NeedDatasource event of the grid with no problem.
I can see updated values in object. But I cannot see those updated values in grid.
I need to refresh the page.
So to refresh the page, I called " this.Page_Load(null, null); "
but no luck.
I have to hit F5 button to refresh the page.

If I remove the code to call Save File Dialogue box, it works perfectly.
There is something wrong with the response of the page.

Could you please help me out?

This is my code :
protected void btnPayment_Click(object sender, EventArgs e)
{
  try
     {
         // Perform some actions...
         

// This code below calls the Save File Dialogue box..

String FilePath = Server.MapPath(".\\GiroPayments\\" + FileName + "");
System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
response.ClearContent();
response.Clear();
response.ContentType = "text/plain";
response.AddHeader("Content-Disposition", "attachment; filename=" + FileName + ";");
response.TransmitFile(FilePath);
response.Flush();
response.End();

rgGiroPayments.Rebind();
this.Page_Load(null, null);

     }
catch()
{}
}
Posted
Comments
Sandeep Mewara 2-Jul-12 6:36am    
You do a Response.End and thus the code after it is not getting executed.
Lokesh Zende 2-Jul-12 6:38am    
yes sandip, thats the reason. Any solution for it?

hi
follow the code

C#
if (!Page.IsPostBack)
        {
            //page will be refereshed at a interval of 10 sec
            Response.AddHeader("Refresh", "10");
        }
 
Share this answer
 
Comments
Lokesh Zende 2-Jul-12 5:16am    
It works only till FileSave Dialogue box opens.
Once I save the file, nothing happens.Page doesn't refresh.
I would suggest to you to do the file download functionality in an iFrame / a popup so that you can work in the main page after downloading the file also, so when you do

Response.End();


It only ends the Response object of the iFrame/popup so that it doesn't ends the main Response Object


Mark it as solution if it answer your question
 
Share this answer
 
There is no way out for this situation.
Once response ends, we cannot get another response as there is only one response to one request.
So I added another button on the form, on click of which, it will refresh my page.
User HAS TO click the button in order to refresh the page.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900