This is a discussion on Exporting GridView to Excel within the ASP and ASP.NET Programming forums, part of the Web Development category; Hi,When i tried to export the data from the gridview to excel I got the following error Could anyone ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| Hi,When i tried to export the data from the gridview to excel I got the following error Could anyone help me out Control 'GridView1' of type 'GridView' must be placed inside a form tag with runat=server. my form tag contains runat ="server"
__________________ Shaalini.S ![]() Be the Best of Whatever you are... |
| Sponsored Links |
| |||
| This is pretty confusing, since your GridView is already inside the form tags and also contains the runat = server attribute. You can easily resolve this error by adding the following lines. public override void VerifyRenderingInServerForm(Control control) { /* Confirms that an HtmlForm control is rendered for the specified ASP.NET server control at run time. No code Required here */ } |
| |||
| Hi blue sky, I have tried with your following code but now i m getting following error RegisterForEventValidation can only be called during Render();
__________________ Shaalini.S ![]() Be the Best of Whatever you are... |
| |||
| Hi shaalini, There are a couple of approches that can be taken to allow for a control to be programmatically rendered without raising the event validation-related exception. The simplest approach is to simply disable event validation for the page. This can be done by setting the EnableEventValidation attribute in the <% @Page %> directive to False: <% @Page EnableEventValidation="False" ... %> If you are using the base Page class technique to override the Page class's VerifyRenderingInServerForm() method, you can always override the EnableEventValidation property there, instead. The other option is to leave the event validation feature enabled, but just wait to programmatically render the control until the Render stage. By doing this, when the control registers for event validation it will be in the Render stage and so the "RegisterForEventValidation can only be called during Render()" exception won't be raised. To accomplish this, you'll need to set some flag in the Button's Click event handler (or wherever you decide to programmatically render the control). |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| GridView.DataBind not working | rrrajesh84in | ASP and ASP.NET Programming | 1 | 03-21-2008 10:01 PM |
| Which is the best among DataList,Repeater and GridView and Why? | poornima | ASP and ASP.NET Programming | 2 | 03-14-2008 08:44 PM |
| GridView Item Tempalte Problem | shaalini | C# Programming | 0 | 01-29-2008 09:11 PM |
| "POST" large amount of data using SendAndLoad (Exporting JPG/JPEG) | aramesh | Flash Actionscript Programming | 2 | 12-28-2007 02:42 AM |
| How to add mouseover function to Gridview..? | kingmaker | C# Programming | 1 | 07-20-2007 12:40 AM |