Hi
I've added the namespace but i still getone error. My code is this:
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
'Get the HTML from GridView1
Dim sw As New IO.StringWriter()
Dim htw As New HtmlTextWriter(sw)
GridView1.RenderControl(htw)
Dim html As String = "<html><body>" + sw.ToString() + "</body></html>"
'Set up the response
Response.Clear()
Response.ContentType = "application/pdf"
'Create pdf document
Dim document As New iTextSharp.text.Document(PageSize.A4, 80, 50, 30, 65)
'Create pdf writer, output directly to OutputStream
Dim writer As iTextSharp.text.pdf.PdfWriter = PdfWriter.GetInstance(document, Response.OutputStream)
Document.Open()
'Create tempfile to hold the HTML:
Dim tempFile As String = Path.GetTempFileName()
Using tempwriter As New IO.StreamWriter(tempFile, False)
tempwriter.Write(html)
End Using
'Parse the HTML into the document
HtmlParser.Parse(Document, tempFile)
'Cleanup
Document.Close()
writer.Close()
'Delete the tempfile:
File.Delete(tempFile)
writer = Nothing
Document = Nothing
Response.[End]()
End Sub
The error is this:
Control 'GridView1' of type 'GridView' must be placed inside a form tag with runat=server.
On this line GridView1.RenderControl(htw)
What else do you suggest?
Thanks for all the help.