public override void VerifyRenderingInServerForm(Control control)
{
// Confirms that an HtmlForm control is rendered for
}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Clear();
Response.Buffer = true;
Response.Charset = "GB2312";
Response.AppendHeader("Content-Disposition", "attachment;filename=FileName.xls");
Response.ContentEncoding = System.Text.Encoding.UTF7;
Response.ContentType = "application/ms-excel";
System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
DataTable dtTmp = (DataTable)this.GridView1.DataSource;
this.GridView1.AllowPaging = false;
GridView1.DataSource = dtTmp;
GridView1.DataBind();
GridView1.RenderControl(oHtmlTextWriter);
Response.Output.Write(oStringWriter.ToString());
this.GridView1.AllowPaging = true;
GridView1.DataSource = dtTmp;
GridView1.DataBind();
Response.Flush();
Response.End();
}