所以我有这段代码
AuditTrailGV.AllowPaging = false;
AuditTrailGV.DataSource = (DataSet)ViewState["audit"];
AuditTrailGV.DataBind();
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
AuditTrailGV.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=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>");
ClientScript.RegisterStartupScript(this.GetType(), "GridPrint", sb.ToString());
AuditTrailGV.AllowPaging = true;
AuditTrailGV.DataSource = (DataSet)ViewState["audit"];
AuditTrailGV.DataBind();
此代码在gridview中打印详细信息,如此
我的问题是我需要在网格上方添加文本,因此它应该如下所示
我需要在打印时添加上面的文本(自由手绘圆圈内的元素:p)
任何帮助?谢谢:)
答案 0 :(得分:0)
你可以这样试试吗?
...
StringWriter sw = new StringWriter();
sw.WriteLine("SYSTEM NAME");
sw.WriteLine("Audit Trail\t\tDate " + DateTime.Now);
HtmlTextWriter hw = new HtmlTextWriter(sw);
AuditTrailGV.RenderControl(hw);
...
我希望这会有所帮助。