title: Unable to render Grid View
body: <p>I have grid view in my user control, and I am getting below error:    </p>
  
  <pre><code>RegisterForEventValidation can only be called during Render();
  </code></pre>
  
  <p>I am using <code>gv.RenderControl(htw);</code></p>
  
  <p>My code is as below:</p>
  
  <pre><code>private void ExportToExcel(string strFileName, GridView gv)
      {
          Response.ClearContent();
          Response.AddHeader("content-disposition", "attachment; filename=" + strFileName);
          Response.ContentType = "application/excel";
          System.IO.StringWriter sw = new System.IO.StringWriter();
          HtmlTextWriter htw = new HtmlTextWriter(sw);
          gv.RenderControl(htw);
          Response.Write(sw.ToString());
          Response.End();
      }
  </code></pre>
  
  <p>And to avoid Server control was created outside form control exception I am using below code:</p>
  
  <pre><code>public override void VerifyRenderingInServerForm(Control control)
  {
      /* Verifies that the control is rendered */
  }
  </code></pre>
  
  <p>But I'm using all this code in a usercontrol, There isn't this method in the base class.
  What should I do, even I placed above in my page in which I place my user control, but still I am getting above error</p>
  
  <p>Also note I am using masterpage in which I have form tagged already.</p>