如何批量打印使用asp.net,C# [英] How to bulk print using asp.net, c#

查看:240
本文介绍了如何批量打印使用asp.net,C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我输入卷没有它显示的名字,在所有科目取得标志和合格/不合格的学生,我可以打印点击打印按钮。但问题是,我想通过点击只有一个[打印]按钮时,连续打印所有的学生记录。
我用循环像这样

When I enter roll no it displays name, marks obtained in all subjects and pass/fail of the student and I can print clicking on print button. But the problem is I want to print all students record continuously by clicking only one time on [Print] button. I used loop like this

for(int i=1;i<studentno.count;i++)
{
     bindgrid(i); // i is the roll no of the student
     Session["ctrl"] = Panel1;
     ClientScript.RegisterStartupScript(this.GetType(), "onclick", "<script language=javascript>window.open('Print.aspx','PrintMe','height=300px,width=300px,scrollbars=1');</script>");
}

但它打印只有最后一个。

But it prints only the last one.

推荐答案

ClientScript.RegisterStartupScript 和您的会话[CTRL] 的变量将在每次循环被覆盖,因此该脚本将只登记在最后一次迭代,你会用面板1 在你的会议VAR的最终状态结束。

The ClientScript.RegisterStartupScript and your Session["ctrl"] variable will be overwritten at each iteration of the loop, so the script will only register at the final iteration and you'll end up with the final state of Panel1 in your Session var.

这真的取决于你的Print.aspx页面的行为,但你可以添加所有绑定的网格(在某些格式,还可能HTML为String)转换成一个ArrayList并将它放入您的会话[CTRL ] 的变量,那么的RegisterStartupScript 在循环后:

It really depends on the behaviour of your Print.aspx page, but you could add all of your bound grids (in some format, perhaps HTML to String) into an ArrayList and put that into your Session["ctrl"] variable, then RegisterStartupScript after the loop:

ArrayList student_grids = new ArrayList();
for(int i=1;i<studentno.count;i++) 
{ 
     bindgrid(i); // i is the roll no of the student 
     student_grids.Add(current_grid); // where current_grid is bound grid at i (in some useful format)
} 
Session["ctrl"] = student_grids;  
ClientScript.RegisterStartupScript(this.GetType(), "onclick", "<script language=javascript>window.open('Print.aspx','PrintMe','height=300px,width=300px,scrollbars=1');</script>");

这篇关于如何批量打印使用asp.net,C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆