惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

The Last Watchdog
The Last Watchdog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
S
Secure Thoughts
MongoDB | Blog
MongoDB | Blog
博客园 - Franky
T
Tor Project blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Google DeepMind News
Google DeepMind News
L
LINUX DO - 最新话题
博客园_首页
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Vercel News
Vercel News
Last Week in AI
Last Week in AI
月光博客
月光博客
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
P
Proofpoint News Feed
博客园 - 叶小钗
NISL@THU
NISL@THU
C
Check Point Blog
K
Kaspersky official blog
N
News and Events Feed by Topic
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
A
Arctic Wolf
T
Threatpost
GbyAI
GbyAI
L
LINUX DO - 热门话题
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
P
Privacy & Cybersecurity Law Blog
N
News and Events Feed by Topic
Scott Helme
Scott Helme
P
Privacy International News Feed
The Register - Security
The Register - Security
G
GRAHAM CLULEY
Recorded Future
Recorded Future
Apple Machine Learning Research
Apple Machine Learning Research
C
Cybersecurity and Infrastructure Security Agency CISA
B
Blog
Project Zero
Project Zero
Cyberwarzone
Cyberwarzone
Webroot Blog
Webroot Blog
Microsoft Security Blog
Microsoft Security Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
D
DataBreaches.Net
J
Java Code Geeks
AWS News Blog
AWS News Blog
Help Net Security
Help Net Security
Engineering at Meta
Engineering at Meta
M
MIT News - Artificial intelligence
T
Threat Research - Cisco Blogs
Google DeepMind News
Google DeepMind News

博客园 - music000

分享:使用JQuery进行跨域请求 Flash Chart 谨防 url 传递参数未编码(转码)产生的陷阱 OSI七层网络模型与TCP/IP四层网络模型 一些数据库理论知识 Sqlserver中Compute By子句用法分析 数据查询的另类需求 A Preview of HTML 5 CSS Sprites 15 Rules for Faster-Loading Web Sites 关于"多级目录(分类)"的一些想法 ----- 实现方法 金额转换:阿拉伯数字转中文(SQL存储过程) 金额转换:阿拉伯数字转中文(javascript) 这两天不爽——公车上被误认为色狼、游泳撞破上嘴唇 如何获取字段中分隔符的个数?(sql语句) 固定表头 Bubble in JavaScript DOM Reg-日期 安装 WebDesigner 之后,ASPNET 帐户没有对 IIS 的访问权。
关于GridView导出Excel的一些问题(采用Ajax出现的的问题及解决方法) - music000 - 博客园
music000 · 2007-08-24 · via 博客园 - music000

以前用GridView导出Excel没碰到什么问题,(注: enableEventValidation  属性必须设置为 "false"——直接在页面设置或在配置文件里设置),但采用Ajax后就出问题了,错误提示:Details Error parsing near '<div><table cells'.

原因:
    导出Excel的按钮放置在<UpdatePanel></UpdatePanel>里面,点击按钮后只输出了“<div><table   cells”,生成的容器表--html代码被截断了

解决方法:
        放到<UpdatePanel></UpdatePanel>外面(注:不要放在任何的<UpdatePanel>     </UpdatePanel>中)

以下为导出Excel方法:

    /// <summary>
    /// 重载方法——VerifyRenderingInServerForm  (必须添加)
    /// </summary>
    /// <param name="control"></param>
    public override void VerifyRenderingInServerForm(Control control)
    {

    }

    /// <summary>
    /// 生成报表
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void ImageButtonexcel_Click(object sender, EventArgs e)
    {
        Response.ClearContent();

        Response.AddHeader("content-disposition", "attachment; filename=MyExcelFile.xls");

        Response.ContentType = "application/excel";

        StringWriter sw = new StringWriter();

        HtmlTextWriter htw = new HtmlTextWriter(sw);

        GridView1.RenderControl(htw);

        Response.Write(sw.ToString());

        Response.End();
    }