Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Sep 17, 2010 12:40 PM by mitunayak
Oct 24, 2007 06:48 AM|LINK
i have one gridview which I need to export it to excel ,
is there any way using VB
I 'm using the following code in the click event of a button on the page
but I'm getting the following error message
" Control 'ctl00_MainContent_GridView1' of type 'GridView' must be placed inside a form tag with runat=server. "
anything I can do .
Oct 24, 2007 08:59 AM|LINK
Have a read of the following article (especially the last paragraph):
Website Design Darlington - http://lessthandot.com -
Oct 24, 2007 09:32 AM|LINK
Put the gridview inside the form tag i.e.
<form id="Form1" method="post" runat="server">
To Export to Excel
Oct 24, 2007 11:01 AM|LINK
thanks for the reply , but I'm getting this error now
any ideas ???
Oct 29, 2007 01:59 AM|LINK
Based on my understanding, you want to export the GridView into Excel in your asp.net VB application. When you try to run it, you get the error message above. If I have misunderstood you, please feel free to let me know.
Sometimes, we can confirm that an HtmlForm control is rendered for the specified ASP.NET server control at run time using VerifyRenderingInServerForm method.
Please try to add the following code in your .aspx.vb file:
Public Overloads Overrides Sub VerifyRenderingInServerForm(ByVal control As Control)
I hope this helps.
Oct 29, 2007 02:11 AM|LINK
RegisterForEventValidation can only be called during Render();
For the this error message, please try to set the EnableEventValidation to false. For example:
<%@ Page Language="VB" EnableEventValidation="false" CodeFile="Default8.aspx.vb" Inherits="Default8" %>
I hope this helps.
May 07, 2008 06:41 PM|LINK
May 07, 2008 07:59 PM|LINK
but gridview must be inside form tags
Nov 02, 2009 09:50 AM|LINK
What you are doing here is basically fooling your browser to redirect this request to Excel program although generated output is HTML.
There are much cleaner ways of exporting to Excel. Check out
GemBox.Spreadsheet and this
web sample demonstrates CSV/XLS/XLSX/ODS/HMTL writing.
Dec 07, 2009 09:41 PM|LINK
The problem is that you also need to overwrite the render() method.
this article helps