1 Replies - 213 Views - Last Post: 16 January 2013 - 02:31 AM

#1 November-06  Icon User is offline

  • D.I.C Regular

Reputation: 46
  • View blog
  • Posts: 391
  • Joined: 04-January 11

Export to Excel

Posted 16 January 2013 - 01:53 AM

The topic title may look simple but I don't have an idea of how to proceed.

I am already done with the code to export the gridview datasource to excel but there is one problem left.

I use C#.NET,ASP.NET, and javascript in this project.

I actually have 7 gridviews. I can use the same code for export for the six tables and it works but not for the last remaining. So what's the difference of my 1 table from the other 6? The last table is being populated using javascript. I used the JSON code that I found in my research on binding a datasource to a gridview using javascript.

So why do I need javascript for this? Mainly because of performance issues. I have a table in which each cell displays a popup when clicked. The popup shows a gridview which is populated dynamically. If I do this server-side, it is too slow for a web application so I decided to use javascript. I did not have an export before but this time I need to add an export to excel function for the table inside the popup.

Now, nothing gets exported. Datasource is null. I deduced that it may be because the datasource wasn't bounded to the gridview server-side. So, the questions that play on my mind are the following:

1. Is there a way I can get the datasource or the rows appended on my gridview via server-side and store it in a datatable so I can export it?
2. If I can't do it server side, is there a way to get the rows of data in my gridview and export it client-side?

It would be a really great help if someone knows how to do this and shares his ideas. A good way to start would be to know how to retrieve the data in the gridview, doesn't matter if it's client or server side. Right now, it really matters to me just to get the data. I can't move forward unless I stop from getting a null datasource.

I hope someone could share some ideas on this.

Is This A Good Question/Topic? 0
  • +

Replies To: Export to Excel

#2 November-06  Icon User is offline

  • D.I.C Regular

Reputation: 46
  • View blog
  • Posts: 391
  • Joined: 04-January 11

Re: Export to Excel

Posted 16 January 2013 - 02:31 AM

About 10 minutes after I posted this code, I did a really big yawn and then the idea came to me. I was populating the gridview using a static function. So all I need to do was retrieve the datatable by calling the function. And it worked.

Sorry to disturb you. I hope that if anyone encounters the same problem, this thread may help him.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1