View Single Post
  #1 (permalink)  
Old February 23rd, 2007, 03:31 PM
rsearing rsearing is offline
Friend of Wrox
Join Date: Jul 2006
Location: olathe, ks, USA.
Posts: 238
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via MSN to rsearing
Default Export DataList to Excel

Can someone please help. I was able to export my Gridview to Excel, but had to use a datalist instead due to some unique bindings I had to place on the contents.

I tried simply changing "GridView" to "DataList" and it didn't work.

Please help.

Kind Regards,

Dim MyGridView As New GridView()
        'MyGridView = GridView1
        MyGridView.DataSource = KnightsDataSource
        Dim attachment As String = "attachment; filename=Members.xls"
        Response.AddHeader("content-disposition", attachment)
        Response.ContentType = "application/ms-excel"
        Dim sw As IO.StringWriter = New IO.StringWriter()
        Dim htw As HtmlTextWriter = New HtmlTextWriter(sw)