/// <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"
时间: 2024-10-09 00:48:05