Introduction:
Here I will explain how to solve the problem Control 'gvdetails' of type 'GridView' must be placed inside a form tag with runat=server during export of gridview to excel or word or csv using asp.net.
Description:
Here I will explain how to solve the problem Control 'gvdetails' of type 'GridView' must be placed inside a form tag with runat=server during export of gridview to excel or word or csv using asp.net.
Description:
In previous post I explained clearly how to show export gridview data to excel,word,notepad and csv using asp.net Export gridview data to Excel,Word . During export a gridview to excel, word, notepad or csv I got error like
Control 'gvdetails' of type 'GridView' must be placed inside a form tag with runat=server
This error occurs whenever I am trying to export gridview data to excel or word or csv because compiler thinks that the control is not added to the form.
To solve this problem I have added one overriding function VerifyRenderingInServerForm event in code behind it solves my problem.
public override void VerifyRenderingInServerForm(Control control) { /* Verifies that the control is rendered */ } |
By Setting adding this function in code behind that problem has solved and code runs successfully.
I hope it helps to solve your problem.
Happy Coding……….
If you enjoyed this post, please support the blog below. It's FREE! Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email. |
|||
|
|||
27 comments :
222
Thank you. It solve my problem.
that's good, Thank you.
Thanks. It solved my Problem.
I have used this code but i am getting error like.,
No suitable method found to override
I have used this code in a visual webpart 2010 but i am getting error like
No suitable method found to override
hi man,
I test you code it gives me the following error:
RegisterForEventValidation can only be called during Render();
Line 39: StringWriter sw = new StringWriter();
Line 40: HtmlTextWriter htw = new HtmlTextWriter(sw);
Line 41: gvdetails.RenderControl(htw);
Line 42: Response.Write(sw.ToString());
Line 43: Response.End();
it works. very good. thanks in advanced
that's thank to code for Gridview data into pdf format Venky Mokka
Thank. i have a problem if content in gridview is another language
i tried code.
but i m getting this error.
(RegisterForEventValidation can only be called during Render();
)
how can i fix it...???
public override void VerifyRenderingInServerForm(Control control)
{
/* Verifies that the control is rendered */
}
This Function are not allow for .ascx Control page.
i am trying it but not successfully implimented.
Unable to cast object of type 'iTextSharp.text.html.simpleparser.CellWrapper' to type 'iTextSharp.text.Paragraph'
how to solve it please help me sir
I have also added this but got error. As I have put EventValidation = "false" this code works.
Thank you Suresh.
You have saved my lots of time in googling and getting better code.
Can anybody tell me what was problem with code?
Why do we need to call the function-VerifyRenderingInServerForm()
thanks nice explanation
can any budy tell me how to attach and send mail on single click in asp.net c#
Thank you very much....It solved my issue.
What is the solution if we get same probkem within the user coltrol not the page.
I have ascx and my gridview is in it.
Sir for sorting i find a solution thanks onceagain for your codes
I get the error when inside a user control.
thanks
Hi,
Additional information: RegisterForEventValidation can only be called during Render();
how can i fix this problem...
how can i Verifies that the control is rendered
registerForEventValidation can only be called during Render();?? help me
Thanks So much
Note: Only a member of this blog may post a comment.