Hey all... I hope this helps someone else out there, because I know that I had trouble trying to get this to work like I wanted to. What I was trying to do was create an order confirmation document of all my data, but I didn't want the user to see the gridview.
So what I did was create my gridview as though I was going to display it will my SQLDataSource and all my columns and then I hid it. Then in the code behind of the button the customer clicked I put this data in it.
If GridView1.Visible = False And GridView2.Visible = False And GridView3.Visible = False And GridView4.Visible = False And _
Panel3.Visible = False And Label3.Visible = False And Label4.Visible = False And Label5.Visible = False And _
Label6.Visible = False Then
GridView1.Visible = True
GridView2.Visible = True
GridView3.Visible = True
GridView4.Visible = True
Panel3.Visible = True
Label3.Visible = True
Label4.Visible = True
Label5.Visible = True
Label6.Visible = True
Response.Clear()
Response.AddHeader("content-disposition", "attachment;filename=Order Confirmation.html")
Response.Charset = ""
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.ContentType = "application/vnd.html"
Dim stringWrite As System.IO.StringWriter = New System.IO.StringWriter
Dim htmlWrite As System.Web.UI.HtmlTextWriter = New HtmlTextWriter(stringWrite)
Panel3.RenderControl(htmlWrite)
Label3.RenderControl(htmlWrite)
GridView1.RenderControl(htmlWrite)
Label4.RenderControl(htmlWrite)
GridView2.RenderControl(htmlWrite)
Label5.RenderControl(htmlWrite)
GridView3.RenderControl(htmlWrite)
Label6.RenderControl(htmlWrite)
GridView4.RenderControl(htmlWrite)
Response.Write(stringWrite.ToString)
Response.End()
End If
Hope it helps. I also formated my gridviews to the way I needed them to be.
None
0 Points
3 Posts
How to export a hidden gridview to a html document
Oct 04, 2006 04:43 PM|jramsey|LINK
Hey all... I hope this helps someone else out there, because I know that I had trouble trying to get this to work like I wanted to. What I was trying to do was create an order confirmation document of all my data, but I didn't want the user to see the gridview. So what I did was create my gridview as though I was going to display it will my SQLDataSource and all my columns and then I hid it. Then in the code behind of the button the customer clicked I put this data in it.
If GridView1.Visible = False And GridView2.Visible = False And GridView3.Visible = False And GridView4.Visible = False And _
Panel3.Visible = False And Label3.Visible = False And Label4.Visible = False And Label5.Visible = False And _
Label6.Visible = False Then
GridView1.Visible = True
GridView2.Visible = True
GridView3.Visible = True
GridView4.Visible = True
Panel3.Visible = True
Label3.Visible = True
Label4.Visible = True
Label5.Visible = True
Label6.Visible = True
Response.Clear()
Response.AddHeader("content-disposition", "attachment;filename=Order Confirmation.html")
Response.Charset = ""
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.ContentType = "application/vnd.html"
Dim stringWrite As System.IO.StringWriter = New System.IO.StringWriter
Dim htmlWrite As System.Web.UI.HtmlTextWriter = New HtmlTextWriter(stringWrite)
Panel3.RenderControl(htmlWrite)
Label3.RenderControl(htmlWrite)
GridView1.RenderControl(htmlWrite)
Label4.RenderControl(htmlWrite)
GridView2.RenderControl(htmlWrite)
Label5.RenderControl(htmlWrite)
GridView3.RenderControl(htmlWrite)
Label6.RenderControl(htmlWrite)
GridView4.RenderControl(htmlWrite)
Response.Write(stringWrite.ToString)
Response.End()
End If
Hope it helps. I also formated my gridviews to the way I needed them to be.