异常:System.Web.HttpException: Control 'GridView1' of type 'GridView' must be placed inside a form tag with runat=server
主要代码如下
//设定导出文件格式
Response.ContentType = "application/vnd.ms~excel";
//设定编码的方式
Response.Charset = "gb2312";
//关闭ViewState
EnableViewState = false;
StringWriter tw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(tw);
this.GridView1.RenderControl(hw);
//把Html写回浏览器
Response.Write(tw.ToString());
Response.End();
??
主要代码如下
//设定导出文件格式
Response.ContentType = "application/vnd.ms~excel";
//设定编码的方式
Response.Charset = "gb2312";
//关闭ViewState
EnableViewState = false;
StringWriter tw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(tw);
this.GridView1.RenderControl(hw);
//把Html写回浏览器
Response.Write(tw.ToString());
Response.End();
??
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货