DataGrid to Excel new window

M

Miguel Ramirez

Hello All,

When exporting from DataGrid to excel, How can I show excel results in a new
window?

I have the following code:

-------
Protected Sub BExcel_onServerClick(ByVal Sender As Object, ByVal E As
EventArgs) Handles BExcel.Click

' Excel Export code

Dim strResult As String = Request("ddlExport_Options")

' Set the content type to Excel.

Response.ContentType = "application/vnd.ms-excel"

' Remove the charset from the Content-Type header.

Response.Charset = ""

' Turn off the view state.

Me.EnableViewState = False

Dim tw As New System.IO.StringWriter

Dim hw As New System.Web.UI.HtmlTextWriter(tw)

' Get the HTML for the control.

DGridResults.RenderControl(hw)

' Write the HTML back to the browser.

Response.Write(tw.ToString())

' End the response.

Response.End()

End Sub





I will appreciate any help you can provide.



Regards,



Miguel.
 
R

Rick Spiewak

You could try puttin tw into session state, and opening a new window which
would use it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top