打印所有网格数据 [英] Printing all grid data
问题描述
我有一个启用分页的gridview。当我打印网格数据时,它只打印一个特定的页面数据。但我需要的是它应该打印所有页面的所有数据。是否可能?如果是的话我怎么能实现这个任务。我被困住了。帮帮我。
提前致谢..
是的,可以打印Gridview中的所有数据
参考这里:
http://www.aspsnippets。 com / Articles / Print-functional-in-ASP.Net-GridView-control.aspx [ ^ ]
Refer- ASP.NET GRIDVIEW控件中的打印功能 [ ^ ]。
< blockquote> protected void btnPrintAllPages_Click(object sender,EventArgs e)
{
GridView1.AllowPaging = false;
GridView1.DataBind();
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
GridView1.RenderControl(hw);
string gridHTML = sw.ToString()。替换(\,')
.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,宽度= 1000,身高= 600,状态= 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());
GridView1.Allo wPaging = true;
GridView1.DataBind();
}
I have a gridview with paging enabled.when i print the grid data it prints only a particular page data.But what i need is it should print all of the data of all pages.Is it possible?If yes how can i achieve this task.I m stuck.Help me out.
Thanks in advance..
Yes it is possible to print all data inGridview
Refer Here:
http://www.aspsnippets.com/Articles/Print-functionality-in-ASP.Net-GridView-control.aspx[^]
Refer- PRINT FUNCTIONALITY IN ASP.NET GRIDVIEW CONTROL[^].
protected void btnPrintAllPages_Click(object sender, EventArgs e)
{
GridView1.AllowPaging = false;
GridView1.DataBind();
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
GridView1.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());
GridView1.AllowPaging = true;
GridView1.DataBind();
}
这篇关于打印所有网格数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!