I recently did some work to export a data table as a Comma Separated Variable file or a MDB file.
The following code allows you to generate a csv from a data table.
To display a link through to a browser, i.e. provide a link on a page where the user can click, get prompted do you wish to open or save this file – put the following in the code behind of the relevant page.
Finally if you are trying to use the code inside an update panel you will need to set the export button as a postback trigger. This can either be done using the following asp.net markup:
or you can set it dynamically in the code behind with the following lines put into the page_load event.
Where smExportCSV is your script manager control.