How is it possible to change the displayed order of columns from a DataTable?
For example, dataTable \"dt\" contains two columns \"a\" and \"b\". I bind it to a Gr
This comes up in an interview question quite often. You are dumping the contents of a table to an excel file which is fine, and you are using html in xl which is fine. BUT - you are taking the contents of the database table and placing it into memory (DataTable). Overtime as this data grows it could use more and more memory on the server, especially if there are concurrent requests for this report!!
Fix: Use a DataReader instead and manually populate the GridView (this solves the problem you posted about) -- or better still use something like Simple OOXML and write the data directly to a xml representation of an .xlsx spreadsheet.