Search code examples
c#excelgridviewentitydatasource

Entitydatasource to Datatable


I have a Gridview that reads the DataSource from an EntityDataSrouce. Now I want to convert the EntityDatasource of the gridview to DataTable so I can export it the Gridview as an Excel file.


Solution

  • You do not need to convert it to DataTable just to export. You can do it by gridview self.

    Look at this link: http://mattberseth.com/blog/2007/04/export_gridview_to_excel_1.html

    In this article, the author uses a utility class that export it to .xls file, so, you can download it, add on your project and use like the sample.