Hi,
I'm trying to print the contents of a datagrid. I want the format of the datagrid to remain, but it is done by css. The following code works for a small datagrid, but not for large datagrid, i.e., the contents go into more than 1 page when print manually:
Response.Clear()
Response.Buffer = True
Response.ContentType = "text/HTML"
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.Charset = ""
EnableViewState = False
Dim oStringWriter As System.IO.StringWriter = New System.IO.StringWriter
Dim oHtmlTextWriter As System.Web.UI.HtmlTextWriter = New System.Web.UI.HtmlTextWriter(oStringWriter)
Dim scr As New StringBuilder
scr.Append("TITLE>View List</TITLE>")
scr.Append("<LINK href='./Styles.css' type='text/css' rel='stylesheet'>")
scr.Append("<script>function window.onafterprint(){history.back(1);}</script" & ">")
oHtmlTextWriter.Write(scr.ToString)
Me.lblCriteria.RenderControl(oHtmlTextWriter)
Me.dagExport.RenderControl(oHtmlTextWriter)
Response.Write(oStringWriter.ToString())
Response.Write("<script>window.print();</script" & ">")
Response.End()
It seems that when I remove the following lines:
scr.Append("TITLE>View List</TITLE>")
scr.Append("<LINK href='./Styles.css' type='text/css' rel='stylesheet'>")
the code works, but my formatting is lost.
Can someone advise me on this problem?
Thanks in advance.
Russ
I'm trying to print the contents of a datagrid. I want the format of the datagrid to remain, but it is done by css. The following code works for a small datagrid, but not for large datagrid, i.e., the contents go into more than 1 page when print manually:
Response.Clear()
Response.Buffer = True
Response.ContentType = "text/HTML"
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.Charset = ""
EnableViewState = False
Dim oStringWriter As System.IO.StringWriter = New System.IO.StringWriter
Dim oHtmlTextWriter As System.Web.UI.HtmlTextWriter = New System.Web.UI.HtmlTextWriter(oStringWriter)
Dim scr As New StringBuilder
scr.Append("TITLE>View List</TITLE>")
scr.Append("<LINK href='./Styles.css' type='text/css' rel='stylesheet'>")
scr.Append("<script>function window.onafterprint(){history.back(1);}</script" & ">")
oHtmlTextWriter.Write(scr.ToString)
Me.lblCriteria.RenderControl(oHtmlTextWriter)
Me.dagExport.RenderControl(oHtmlTextWriter)
Response.Write(oStringWriter.ToString())
Response.Write("<script>window.print();</script" & ">")
Response.End()
It seems that when I remove the following lines:
scr.Append("TITLE>View List</TITLE>")
scr.Append("<LINK href='./Styles.css' type='text/css' rel='stylesheet'>")
the code works, but my formatting is lost.
Can someone advise me on this problem?
Thanks in advance.
Russ