The following error occurs when importing data to excel in the gridview:
Control "DG" of Type 'gridview 'must be placed inside a form tag with runat = Server
This function is missing after searching the online data:
Public Override VoidVerifyrenderinginserverform (ControlControl)
{
// Base. verifyrenderinginserverform (control );
}
If no page is set for your gridview, it can be executed normally. However, if the page is set, another problem will soon be encountered!
Another error occurs after compilation and execution,The following error message is displayed:
RegisterforeventvalidationCan only be called during render ();
To solve this problem, you can set the following two settings in the original aspx file <% PAGE %>.
Enableeventvalidation = "false" autoeventwireup = "true"
after the above two statements are added to the ASPX page, they are executed normally.