2010-12-09 8 views
1

Bonjour à tous, j'ai essayé le code ci-dessous pour faire l'exportation vers Excel, mais ne fonctionne pas correctement i utilisé ce fil link textGridView exporter vers Excel erreur

HtmlForm form = new HtmlForm(); 
string attachment = "attachment; filename=Patients.xls"; 
Response.ClearContent(); 
Response.AddHeader("content-disposition", attachment); 
Response.ContentType = "application/ms-excel"; 
StringWriter stw = new StringWriter(); 
HtmlTextWriter htextw = new HtmlTextWriter(stw); 
form.Controls.Add(gridview1); 
this.Controls.Add(form); 
form.RenderControl(htextw); 
Response.Write(stw.ToString()); 
Response.End(); 

Répondre

1

avez-vous essayez ajouter à la directive page ASPX

EnableEventValidation ="false"