Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > Visual Web Developer 2005
|
Visual Web Developer 2005 Discuss creating ASP.NET 2.0 sites with Microsoft's Visual Web Developer 2005. If your question is more specific to a piece of code than the Visual tool, see the ASP.NEt 2.0 forums instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Web Developer 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 23rd, 2010, 03:19 AM
Authorized User
Points: 410, Level: 7
Points: 410, Level: 7 Points: 410, Level: 7 Points: 410, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2009
Posts: 72
Thanks: 17
Thanked 0 Times in 0 Posts
Question Details View Data export in Excel Sheet

Hi,

I have 3 DetailsView Data Controls on my .aspx page.
These 3 Controls Display data from 3 different tables from a Access Database.

I want to Export the Data of these 3 Data Controls in an Excel sheet.

SO I used the following code :-
Private Sub ExportToExcel(ByVal strFileName As String, ByVal dg As DetailsView)
Response.Clear()
Response.Buffer = True
Response.ContentType = "application/vnd.ms-excel"
Response.Charset = ""
Me.EnableViewState = False
Dim oStringWriter As New System.IO.StringWriter
Dim oHtmlTextWriter As New System.Web.UI.HtmlTextWriter(oStringWriter)

DetailsView1.RenderControl(oHtmlTextWriter)

Response.Write(oStringWriter.ToString())
Response.[End]()
End Sub

Protected Sub ExcelButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ExcelButton1.Click
ExportToExcel("Report.xls", GridView1)
End Sub


But its showing me Error :-
Control 'DetailsView1' of type 'DetailsView' must be placed inside a form tag with runat=server.
Line 18: DetailsView1.RenderControl(oHtmlTextWriter)



But the <form> tag with runat="server" is already there.

How to solve this & if there is some other code to export the data to Excel.


Thank You......!!

-Anup





Similar Threads
Thread Thread Starter Forum Replies Last Post
Export Values to Excel Sheet from Sub form ayazhoda Access VBA 3 June 12th, 2012 03:18 PM
Gridview data export to excel sheet abhishekkashyap27 C# 2005 1 August 1st, 2008 10:10 AM
Export data from a datalist to an Excel sheet see07 ASP.NET 1.x and 2.0 Application Design 3 February 23rd, 2007 07:20 PM
How To Export a specific Excel Sheet as a csv file mrjits Excel VBA 5 August 1st, 2006 03:04 PM
Export Image to Excel sheet haribala.raj General .NET 0 September 13th, 2005 11:56 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.