exportar datagrid a excel

george
14 de Junio del 2006
Tengo el cdigo este:
Response.Clear()
Response.Buffer = True
Response.Charset = \\\"\\\"
Response.ContentEncoding = System.Text.Encoding.UTF8
Response.AppendHeader(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"Content-Disposition\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\", \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"attachment;Filename=test.xls\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\")
Response.ContentType = \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"application/vnd.ms-excel\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"
Me.EnableViewState = False
Dim tw As New System.IO.StringWriter
Dim hw As New System.Web.UI.HtmlTextWriter(tw)
grdResources.RenderControl(hw)
Me.Controls.Clear()
Response.Write(tw.ToString())
Response.End()

Esto me exporta un datagrid a un excel, el problema es que cuando me sale la ventana para requerir una accin y hago click en abrir, me sale otra vez la misma ventana, y entonces cuando le doy otra vez, ya es cuando me lo abre. A ver si alguien me puede exar una mano.