Hi i have been using this code
for using button "print all page" in my company e-leave. It is successfull , but when i want to print gridview for filter page it went out to printed the latest record which is not the filter page that i want. How can i print gridview for the filter page? This is my code for C#
<pre>public override void VerifyRenderingInServerForm(Control control)
{
}
protected void OnPaging(object sender, GridViewPageEventArgs e)
{
gvTranList.PageIndex = e.NewPageIndex;
gvTranList.DataBind();
}
protected void PrintAllPages(object sender, EventArgs e)
{
gvTranList.AllowPaging = false;
gvTranList.Columns[8].Visible = false;
gvTranList.Columns[9].Visible = false;
gvTranList.DataBind();
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
gvTranList.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());
gvTranList.AllowPaging = true;
gvTranList.DataBind();
gvTranList.Columns[8].Visible = true;
gvTranList.Columns[9].Visible = false;
}
}
What I have tried:
Print Current Page and Print All Pages of GridView[
^]