Click here to Skip to main content
15,612,565 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have an Asp.Net GridView that contains 205 columns.

I can export it to an Excel with the save as prompt. The export to excel is working properly.

My question here is can I create a simple LinkButton on the home page that says 'Export to Excel' without showing the entire GridView on a certain page?

1 solution

Yes, why not.

Just use the DataTable directly. Export DataTable to Excel. There is no need to bind the GridView.
Share this answer
gtan018 4-Oct-13 15:09pm    
Great. I will try that route. Do you have an example code without binding it to the gridview? If not I will give it a shot and let you know.
You can find that easily by Googling "DataTable to Excel +".
gtan018 4-Oct-13 16:03pm    
Thank you Tadit Dash. I got it worked out by creating a DataTable and binding it to that. I than created a link button that will export the data to an excel without a gridview. Works great. Now I have to format certain cells to a text. Thanks again.
Good news. Well done buddy. Keep up the good work.

Thanks for accepting the answer. :)

Sergey Alexandrovich Kryukov 4-Oct-13 15:17pm    
Good point, a 5. It's better not to put turn the design inside out.

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