Gridview1.rendercontrol Error
Contents |
here for a quick overview control 'gridview' of type 'gridview' must be placed inside a form tag with runat=server of the site Help Center Detailed answers to any
Gridview Rendercontrol
questions you might have Meta Discuss the workings and policies of this site
Registerforeventvalidation Can Only Be Called During Render();
About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack
Gridview Rendercontrol Excel
Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Export gridview data verifyrenderinginserverform no suitable method found to override to a excel sheet is giving error up vote 0 down vote favorite I have a asp.net application where in i am displaying a grid view whose code is shown below
|
ASP.NET Community Standup Forums Help Home/ASP.NET Forums/Advanced ASP.NET/HttpHandlers and HttpModules/Gridview Export to Excel - RenderControl error Gridview Export to Excel - RenderControl verifies that the control is rendered error [Answered]RSS 3 replies Last post Jan 28, 2011 09:15 AM rendercontrol must be placed inside a form tag with runat server by march11 ‹ Previous Thread|Next Thread › Print Share Twitter Facebook Email Shortcuts Active Threads Unanswered Threads verifyrenderinginserverform export to excel Unresolved Threads Support Options Advanced Search Reply march11 Participant 1929 Points 1917 Posts Gridview Export to Excel - RenderControl error Jan 27, 2011 09:10 AM|march11|LINK I am using http://stackoverflow.com/questions/20781809/export-gridview-data-to-a-excel-sheet-is-giving-error the following code to export a Gridview to an Excel spreadsheet. It works great until I select more than 10records.At the 11th record Iget an error on the line of code that reads.... GridView1.RenderControl(hw) The error reads.... RegisterForEventValidation can only be called during Render(); Description: An unhandled exception occurred during the execution of the current web request. http://forums.asp.net/t/1647006.aspx?Gridview+Export+to+Excel+RenderControl+error Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.InvalidOperationException: RegisterForEventValidation can only be called during Render(); Source Error: Line 155: End If Line 156: Next Line 157: GridView1.RenderControl(hw) Line 158: Line 159: 'style to format numbers to string Sub: Response.Clear() Response.Buffer = True Response.AddHeader("content-disposition", "attachment;filename=GridViewExport.xls") Response.Charset = "" Response.ContentType = "application/vnd.ms-excel" Dim sw As New StringWriter() Dim hw As New HtmlTextWriter(sw) 'Change the Header Row back to white color GridView1.HeaderRow.Style.Add("background-color", "#FFFFFF") For x As Integer = 0 To GridView1.Columns.Count - 1 'Apply style to Individual Cells GridView1.HeaderRow.Cells(x).Style.Add("background-color", "red") Next For i As Integer = 0 To GridView1.Rows.Count - 1 Dim row As GridViewRow = GridView1.Rows(i) 'Change Color back to white row.BackColor = System.Drawing.Color.White 'Apply text style to each Row row.Attributes.Add("class", "textmode") 'Apply style to Individual Cells of Alternating Row If i Mod 2 <> 0 Then For y As Integer = 0 To GridView1.Columns.Count - 1 row.Cells(y).Style.Add("background-color", "#C2D69B") 'row.Cells(1).Style.Add("background-color", "#C2D69B") 'row.Cells(2).Style.Add("background-color", "#C2D69B") 'row.Cells(3).Style.Add("background-color", "#C2D69B") Next
Latest Articles Latest Tips/Tricks Top Articles Beginner Articles Technical Blogs Posting/Update Guidelines Article Help Forum Article http://www.codeproject.com/Articles/21127/RenderControl-doesn-t-work-for-GridView Competition Submit an article or tip Post your Blog quick answersQ&A Ask a Question about this article Ask a Question View Unanswered Questions View All Questions... C# questions Linux questions ASP.NET questions SQL questions VB.NET questions discussionsforums All Message Boards... Application Lifecycle> Running a Business Sales / Marketing Collaboration / Beta Testing must be Work Issues Design and Architecture ASP.NET JavaScript C / C++ / MFC> ATL / WTL / STL Managed C++/CLI C# Free Tools Objective-C and Swift Database Hardware & Devices> System Admin Hosting and Servers Java .NET Framework Android iOS Mobile SharePoint Silverlight / WPF Visual Basic Web Development Site Bugs / Suggestions must be placed Spam and Abuse Watch features Competitions News The Insider Newsletter The Daily Build Newsletter Newsletter archive Surveys Product Showcase Research Library CodeProject Stuff communitylounge Who's Who Most Valuable Professionals The Lounge The Insider News The Weird & The Wonderful The Soapbox Press Releases Non-English Language > General Indian Topics General Chinese Topics help What is 'CodeProject'? General FAQ Ask a Question Bugs and Suggestions Article Help Forum Site Map Advertise with us About our Advertising Employment Opportunities About Us Articles » Web Development » ASP.NET Controls » Grid Controls ArticleBrowse CodeStatsRevisions (3)Alternatives Comments (5) Add your ownalternative version Tagged as C#.NETWindowsVisual-StudioWebFormsASP.NETDesignDev Stats 53.3K views9 bookmarked Posted 31 Oct 2007 RenderControl doesn't work for GridView Rajesh Thomas, 31 Oct 2007 CPOL 2.07 (5 votes) 1 2 3 4 5 2.07/5 - 5 votesμ 2.07, σa 3.59 [?] Rate this: Please Sign up or sign in to vote. The RenderConrol method of Dat