how to use PreExport feature ???

Feb 21, 2012 at 10:32 AM
Edited Feb 21, 2012 at 10:34 AM

I am using a gridview to bind my data at runtime but when i click the export to excel button only the datafields of the Gridview  are displayed and not the content of the gridview.

the code of my document is as follows.. please help...


MySqlConnection conn = new MySqlConnection(System.Configuration.ConfigurationManager.AppSettings["CONSTR"].ToString());       

string query = "select * from blahblah";       

MySqlDataAdapter adp = new MySqlDataAdapter(query, conn);       

DataSet ds=new DataSet();       


if (ds.Tables[0].Rows.Count > 0)       


GridView1.Visible = true;           

GridView1.DataSource = ds;           


ExportToExcel1.PreExport += new KrishLabs.Web.Controls.ExportToExcel.PreExportEventHandler(ExportToExcel1_PreExport);       




GridView1.Visible = false;                          


Mar 1, 2012 at 2:54 PM

Dear B --

I think that you need to rebind your data in the PreExport event.

Look at this...

>>> 11) PreExport Event - For those of you who dynamically bind the GridView at runtime, use this new event to databind the GridView just before "Exporting"

...which is found at this link...

...and maybe that will be of some help.

It means that if one does programmatic binding (that is, binding done in the code-behind), then one must re-bind the data in the PreExport event.



-- Mark Kamoski