GridView control "must be placed inside a form tag with runat=server"

I tried to follow up Ram's suggestion and exported data in a GridView to a word documents by following code snippet:

 

代码

 

After building the project and try to view it in browser, however, the browser just told me the following message when clicking the Export data button:
 Error Message

 

 

 

 

 

 

 

 

 

 

 

 

After a quick search, I found: http://rstew.blogspot.com/2007/10/gridview-must-be-placed-inside-form-tag.html, great post, override the VerifyRenderingInServerForm method, the process works happily!

public override void VerifyRenderingInServerForm(Control control)

{

      return;

}

 

posted @ 2009-11-27 19:02  Roahn Luo  阅读(1112)  评论(0编辑  收藏  举报