GridView中创先争优 [英] gridview to excel

查看:133
本文介绍了GridView中创先争优的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在asp.net vs05.when我出口的GridView工作创先争优,比我得到下面的错误

RegisterForEventValidation只能在渲染(被称为);

为什么我得到这个错误。如何解决呢?

 公共无效ToExcel()
{
    字符串附件=附件;文件名= Employee.xls;
            Response.ClearContent();
            Response.AddHeader(内容处置,附件);
            Response.ContentType =应用程序/ MS-Excel的;
            StringWriter的STW =新的StringWriter();
            HtmlTextWriter的htextw =新的HtmlTextWriter(STW);
            gvSearch.RenderControl(htextw);
            的Response.Write(stw.ToString());
            到Response.End();
}
 公共覆盖无效VerifyRenderingInServerForm(控制控制)
    {    }


解决方案

在aspx页面,更改以下为false:AllowPaging =FALSEAllowSorting =假,并删除每页=10

work on asp.net vs05.when i export gridview to excel than i get the below error

RegisterForEventValidation can only be called during Render();

why i get this error .How to solve it?

public void ToExcel()
{
    string attachment = "attachment; filename=Employee.xls";
            Response.ClearContent();
            Response.AddHeader("content-disposition", attachment);
            Response.ContentType = "application/ms-excel";
            StringWriter stw = new StringWriter();
            HtmlTextWriter htextw = new HtmlTextWriter(stw);
            gvSearch.RenderControl(htextw);
            Response.Write(stw.ToString());
            Response.End(); 
}


 public override void VerifyRenderingInServerForm(Control control)
    {

    }

解决方案

in aspx page, Change the following to false : AllowPaging="False" AllowSorting="False" and remove Pagesize="10".

这篇关于GridView中创先争优的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆