110,539
社区成员
发帖
与我相关
我的任务
分享
protected void Button2_Click(object sender, EventArgs e)
{
GridView1.AllowPaging = false;
GridView1.GridLines = GridLines.Both;
GVDataBind(sqlstr());
Export("application/ms-excel", "ErrorData.xls");
GridView1.AllowPaging = true;
GridView1.GridLines = GridLines.None;
GVDataBind(sqlstr());
}
private void Export(string FileType, string FileName)
{
Response.Charset = "GB2312";
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName, Encoding.UTF8).ToString());
Response.ContentType = FileType;
this.EnableViewState = false;
StringWriter tw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(tw);
GridView1.RenderControl(hw);
Response.Write(tw.ToString());
Response.End();
}
public override void VerifyRenderingInServerForm(Control control)
{ }