Dear all,
I am using update panel on my page and want to print a gridview.
If i remove the update panel, the below code is working..
Following is my code
Protected Sub btnPrint_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnPrint.Click
gvDetails.PagerSettings.Visible = False
gvDetails.Visible = True
gvDetails.AllowPaging = False
gvDetails.DataSource = dt
gvDetails.DataBind()
Dim sw As New StringWriter()
Dim hw As New HtmlTextWriter(sw)
gvDetails.RenderControl(hw)
Dim gridHTML As String = sw.ToString().Replace("""", "'").Replace(System.Environment.NewLine, "")
Dim sb As New StringBuilder()
sb.Append("<script type = 'text/javascript'>")
sb.Append("window.onload = new function(){")
sb.Append("var printWin = window.open('', '', 'left=0")
sb.Append(",top=0,width=1000,height=600,status=0');")
sb.Append("printWin.document.write(""")
sb.Append(gridHTML)
sb.Append(""");")
sb.Append("printWin.document.close();")
sb.Append("printWin.focus();")
sb.Append("printWin.print();")
sb.Append("printWin.close();};")
sb.Append("</script>")
ScriptManager.RegisterStartupScript(Me, Me.GetType(), "Print", sb.ToString(), True)
gvDetails.PagerSettings.Visible = True
gvDetails.DataBind()
gvDetails.Visible = False
end sub
its showing me nothing
thanks
nick