p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   ASP.NET 2.0 Professional (http://p2p.wrox.com/forumdisplay.php?f=215)
-   -   Export DataList to Excel (http://p2p.wrox.com/showthread.php?t=54510)

rsearing February 23rd, 2007 03:31 PM

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,
Rob

Dim MyGridView As New GridView()
        'MyGridView = GridView1
        MyGridView.DataSource = KnightsDataSource
        MyGridView.DataBind()
        Dim attachment As String = "attachment; filename=Members.xls"
        Response.ClearContent()
        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)
        MyGridView.RenderControl(htw)
        Response.Write(sw.ToString())
        Response.End()



All times are GMT -4. The time now is 07:17 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.