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();
答案 0 :(得分:1)
您是否尝试添加到aspx页面指令
EnableEventValidation ="false"