Error message: the control "gridview1" of the type "gridview" must be placed in the form tag with runat = server.

Source: Internet
Author: User

Error message: the control "gridview1" of the type "gridview" must be placed in the form tag with runat = server.

When exporting data to an excel program, an error message is displayed: the "gridview1" control type "gridview" must be placed in a form tag with runat = server.

Generally, this is because the <form> label does not contain runat = "server ". But this is in the program! Finally, I checked a lot of information and finally solved the problem.

Reload the verifyrenderinginserverform method in the background file, for example :/? "
Public override void verifyrenderinginserverform (Control)
{
// Base. verifyrenderinginserverform (control );
}

PS: verifyrenderinginserverform method description

Page. verifyrenderinginserverform Method
Make sure that the htmlform control is displayed for the specified ASP. NET Server Control at runtime.

[C #] Public Virtual void verifyrenderinginserverform (control); Parameter
Control
ASP. NET Server Control, which must be in the htmlform control.
Exception
Exception type condition
The server control specified by httpexception is not included between the start and end mark of the htmlform Server Control at runtime.

Remarks
If the page is not currently in the rendering phase of page processing and is in the <form runat = Server> flag, this method will cause an exception. Must be in the server form

You can call this method during rendering so that explicit error messages are displayed when they are placed outside. The control that sends back or depends on the registered script block should be in

This method is called in the override of control. Render method. You can rewrite this method for different pages that render server form elements to cause exceptions under different conditions.

If the server controls that return or use client scripts are not included in the htmlform Server Control (<form runat = "server">), they will not work properly

. These controls can call this method during rendering to provide clear error information when they are not included in the htmlform control.

This method is usually called when the render method is rewritten for any type of input tag during custom server control development. This is called in the input control.

It is particularly important when getpostbackeventreference or sending client scripts. This call is not required for composite server controls.

Do not override this method unless you want to create a replacement page framework.

 

This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/chenguang79/archive/2010/03/16/5387077.aspx

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.