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

推荐订阅源

S
Secure Thoughts
Security Latest
Security Latest
Simon Willison's Weblog
Simon Willison's Weblog
O
OpenAI News
GbyAI
GbyAI
L
LINUX DO - 最新话题
A
Arctic Wolf
T
Tor Project blog
G
GRAHAM CLULEY
I
InfoQ
博客园_首页
IT之家
IT之家
The Register - Security
The Register - Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Proofpoint News Feed
The GitHub Blog
The GitHub Blog
Blog — PlanetScale
Blog — PlanetScale
N
Netflix TechBlog - Medium
K
Kaspersky official blog
博客园 - 三生石上(FineUI控件)
S
SegmentFault 最新的问题
U
Unit 42
PCI Perspectives
PCI Perspectives
量子位
P
Palo Alto Networks Blog
S
Securelist
T
Troy Hunt's Blog
博客园 - 【当耐特】
Recorded Future
Recorded Future
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
S
Security Affairs
Engineering at Meta
Engineering at Meta
T
The Blog of Author Tim Ferriss
博客园 - 聂微东
罗磊的独立博客
N
News and Events Feed by Topic
人人都是产品经理
人人都是产品经理
B
Blog RSS Feed
NISL@THU
NISL@THU
C
Cisco Blogs
T
Threatpost
有赞技术团队
有赞技术团队
Forbes - Security
Forbes - Security
Hugging Face - Blog
Hugging Face - Blog
Last Week in AI
Last Week in AI
T
The Exploit Database - CXSecurity.com
Cloudbric
Cloudbric
Cyberwarzone
Cyberwarzone
Google DeepMind News
Google DeepMind News
C
Cyber Attacks, Cyber Crime and Cyber Security

博客园 - bela liu

生成PDF文档,并在PDF文档结尾加印章 EF CodeFirst 学习 1 - 用fluent API设置元数据, silverlight: 关于dataform的commit silverlight:datagrid滚动 win7下chm打不开 MS DTC 无法正确处理DC升级/降级事件。MS DTC 将继续运行并使用现有的安全设置。 远程桌面如果超出最大连接数, 使用命令行mstsc /console登录即可。 windows server 2008 安装live mail windows server 2008 安装 MSN Help: DCOM中设定"launch permission"的问题 Qt 学习(1) 使用firefox的一个小技巧 - bela liu - 博客园 现有一车(千里马)过年从苏州回赣榆,15号或者17号出发,21号,23号或者25号返程。 在Oracle中申明与某个字段类型相同的变量 几道Python的习题 在ReportViewer中使用超链接(HyperLink) 在window.showModelessDialog打开的窗体中调用原窗体的alert会使IE死掉。 [转]面向对象与数据模型 在模式窗体中提交而不打开新窗体
未解之Bug (1) : 必须放在具有 runat=server 的窗体标记内
bela liu · 2006-10-09 · via 博客园 - bela liu

在试图将GRIDVIEW中的数据导出至EXCEL时抛出异常:

类型“GridView”的控件“ctl00_contentBody_gridView4Export”必须放在具有 runat=server 的窗体标记内。

 页面是从母版页继承的,而gridview所在的ContentPlaceHolder确定是放在form中的。

以前只有控件未放在form中才会抛出同类异常。

 1 protected void btExport_Click(object sender, EventArgs e)
 2     {
 3         // get dataset
 4         SRMReportService.ReportService srv = ServiceFactory.ReportService();
 5         DataSet ds = srv.QueryAllData_Vendor_CheckAmount_Summary(
 6             (string)this.ViewState["PlantCode"],
 7             (string)this.ViewState["PeriodCode"],
 8             (string)this.ViewState["VendorCode"]);
 9 
10         // bind to gridview
11         this.gridView4Export.DataSource = ds;
12         this.gridView4Export.DataBind();
13 
14         // export
15         this.ExportToExcel(this.gridView4Export);
16     }
17 
18 
19 
20 
21     public void ExportToExcel(System.Web.UI.Control ctl)
22     {
23 
24         Response.AppendHeader("Content-Disposition"
25             "attachment;filename=Excel.xls");
26         Response.ContentEncoding = 
27             System.Text.Encoding.GetEncoding("GB2312");
28         Response.ContentType = "application/ms-excel";
29         
30         System.Globalization.CultureInfo myCItrad = 
31             new System.Globalization.CultureInfo("ZH-CN"true);
32         System.IO.StringWriter tw = 
33             new System.IO.StringWriter(myCItrad);
34         try
35         {
36             System.Web.UI.HtmlTextWriter hw = new HtmlTextWriter(tw);
37             ctl.RenderControl(hw);
38             Response.Write(tw.ToString());
39             Response.End();
40         }
41         finally
42         {
43             tw.Close();
44         }
45     }
46