异常: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();
??