Asp.Net Hein

Asp.Net Hein

  • NA
  • 266
  • 166.4k

Grid view print

May 12 2015 5:12 AM
grvcourse.AllowPaging = false;
grvcourse.DataBind();
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
grvcourse.RenderControl(hw);
string gridHTML = sw.ToString().Replace("\"", "'")
.Replace(System.Environment.NewLine, "");
StringBuilder sb = 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=300,height=300,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>");
ClientScript.RegisterStartupScript(this.GetType(), "GridPrint", sb.ToString());
grvcourse.AllowPaging = true;
grvcourse.DataBind();
This is my code.The printing process is work , but after the printing, there is nothing in printed file. Is like blank.
Can anyone help me?
Thanks a lot for viewing my post. :-) 
 

Answers (3)