标签:
/// <summary> /// 导出分页 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnExport_Click(object sender, EventArgs e) { Response.Clear(); Response.AddHeader("content-disposition", "attachment;filename=FileName.xls"); Response.Charset = "gb2312"; Response.ContentType = "application/vnd.xls"; System.IO.StringWriter stringWrite = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite); gvScenic.AllowPaging = false; bindData(); gvScenic.RenderControl(htmlWrite); Response.Write(stringWrite.ToString()); Response.End(); gvScenic.AllowPaging = true; bindData(); }
加入form=ruanserver验证,否则报错
public override void VerifyRenderingInServerForm(Control control) { }
前台页面加入
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="test.aspx.cs" Inherits="testtest" EnableEventValidation = "false" %>
EnableEventValidation = "false"
标签:
原文地址:http://www.cnblogs.com/ilooking/p/4768896.html