Click here to Skip to main content
15,894,410 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I've got a couple of buttons which export some tables to Excel. I have a label control which I use to report any errors.

When I click a button and there's no records to export, I set my label's text accordingly. However, when I then click on the other button and there are records to export, the spreadsheet is generated but the label value doesn't change as no postback seems to occur even though I try to set the label's text to the number of records found.

There's nothing special about the Excel export functionality - it's just the usual configure an HttpResponse, add a suitable header, render a DataGrid control to an HTMLTextWriter and do a Response.Write() followed by a Response.End().

Can anyone help?

Thanks :)
Posted
Updated 24-Aug-10 8:03am

1 solution

What happens here is, that your Excel export sends a response to the client browser.

Due to the mime type, the browser knows that is is an attachment do download, rather than a website to display.

So it opens the new response and saves int to your local disk, but does not reload the current page.

To be honest, I am unsure whether/how to achieve this; I would try experimenting with some AJAX, Update Panels, and the like...

Cheers
Uwe
 
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