Answered by:
Visual webpart gridview control Export to Excel

Question
-
Hi,
I am trying to implement export to excel using visual webpart, first I got the error put "I am getting error on
GridView1.RenderControl(htw);
line and the error isControl 'ctl00_ContentPlaceHolder1_GridView1' of type 'GridView' must be placed inside a form tag with runat=server.
",And when I am usingpublic override void VerifyRenderingInServerForm(Control control)
{
/* Confirms that an HtmlForm control is rendered for the specified ASP.NET
server control at run time. */
}I am getting error that it cannot be overridden .How to resolve this issue
Saturday, April 18, 2015 2:41 AM
Answers
-
Hi,
If you want to export gridview to Excel in visual web part, I suggest you refer to the following articles to achieve it.
ASP.Net 2.0: Export GridView to Excel
Export Gridview to Excel in Sharepoint (ascx)
http://forums.asp.net/t/1461411.aspx?Export+Gridview+to+Excel+in+Sharepoint+ascx+Export to Excel - From SharePoint user control based web part
http://www.sharepointdiary.com/2011/02/export-to-excel-from-sharepoint-user-control-webpart.html
TechNet Community Support
Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.- Proposed as answer by Patrick_Liang Saturday, April 25, 2015 3:12 AM
- Marked as answer by Patrick_Liang Tuesday, April 28, 2015 11:49 AM
Monday, April 20, 2015 9:07 AM
All replies
-
hi
add <form runat="server">...</form> to your master page around content placeholder which then will be used for web part zones where web part will be added. VerifyRenderingInServerForm can't be overridden inside control because it is defined in Page class, i.e. you need to call it like that inside control:
this.Page.VerifyRenderingInServerForm(this);
Blog - http://sadomovalex.blogspot.com
Dynamic CAML queries via C# - http://camlex.codeplex.comSaturday, April 18, 2015 9:01 AM -
I cannot have permission to modify master page..it is already developed and getting used in production..i need to provide this webpart to that site collection. So is there any alternative way to do this?Saturday, April 18, 2015 5:17 PM
-
Hi,
If you want to export gridview to Excel in visual web part, I suggest you refer to the following articles to achieve it.
ASP.Net 2.0: Export GridView to Excel
Export Gridview to Excel in Sharepoint (ascx)
http://forums.asp.net/t/1461411.aspx?Export+Gridview+to+Excel+in+Sharepoint+ascx+Export to Excel - From SharePoint user control based web part
http://www.sharepointdiary.com/2011/02/export-to-excel-from-sharepoint-user-control-webpart.html
TechNet Community Support
Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.- Proposed as answer by Patrick_Liang Saturday, April 25, 2015 3:12 AM
- Marked as answer by Patrick_Liang Tuesday, April 28, 2015 11:49 AM
Monday, April 20, 2015 9:07 AM