GridView1.AllowPaging = false;
//string path = Server.MapPath("Draw.xls");
Response.ClearContent();
Response.AddHeader("content-disposition", "attachment; filename=Draw.xls");
Response.ContentType = "application/excel";
Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
GridView1.RenderControl(htw);
Response.Write(sw.ToString());
Response.End();
GridView1.AllowPaging = true;
增加一空方法
public override void VerifyRenderingInServerForm(Control control)
{
}