Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

Posted

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...