Hellllpppppp

niall29

Freshman
Joined
Sep 13, 2004
Messages
35
I have a web page with a datagrid of results from a query, then with a press of a button it exports the details to Excel which is working great but I want it when the page loads it automatically turns on Auto filter.

Can any one help me with this.
Any help would be greatly appreciated.
 
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
 
Back
Top