As you can see by my code below I tried a few ideas befor I got it to work see if this helps you or if you need more info I will try yo make in to better English.
DataGrid1.DataSource = RDR
DataGrid1.DataBind()
DataGrid1.Visible = True
' Verify if the page is to be displayed in Excel.
If Label1.Text = "1" Then
'Dim xl As New Excel.Application
'Dim wbk As Excel.Workbook
'xl.Visible = True
'wbk = xl.Workbooks.Add
'wbk.Sheets.Add()
'' wbk.ActiveSheet.Cells(1, 1).AutoFilter()
'wbk.ActiveSheet.Cells(1, 1).CopyFromRecordset(DataGrid1)
' If Request.QueryString("bExcel") = "1" Then
' Set the content type to Excel.
Response.ContentType = "application/vnd.ms-excel"
' Remove the charset from the Content-Type header.
Response.Charset = ""
Response.
' Turn off the view state.
Me.EnableViewState = True
Dim tw As New System.IO.StringWriter
Dim hw As New System.Web.UI.HtmlTextWriter(tw)
' Get the HTML for the control.
DataGrid1.RenderControl(hw)
' Write the HTML back to the browser.
Response.Write(tw.ToString())
' End the response.
Response.End()
' Response.ContentType("A:A")Selected)
End If
Conn.Close()
End Sub