如何使用复选框打印多个页面? [英] How to print multiple pages using checkbox?
本文介绍了如何使用复选框打印多个页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我选中复选框并单击打印按钮时,我想打印多个页面。但我没有得到正确的输出。任何人都可以帮助我查询
I want to print Multiple pages when I check the Checkbox and click the print button. But i am not getting the correct output. Can Anyone help me with my Query
protected void btnPrint_Click(object sender, EventArgs e)
{
PrintDocument pdoc = new PrintDocument();
foreach (GridViewRow row in GVCloneList.Rows)
{
if (row.RowType == DataControlRowType.DataRow)
{
CheckBox chkRow = (row.Cells[0].FindControl("ChkPrnt") as CheckBox);
if (chkRow.Checked)
{
String Id = chkRow.ToolTip;
DataTable Dtable = clDl.Select(Convert.ToInt32(Id)).Tables[0];
StringBuilder sb = new StringBuilder();
string qs = "";
try
{
// start creating page with title and date/time
sb.Append("ID : " + Dtable.Rows[0]["Clone_Id"].ToString() + "\n\n");
// iterate submitted form fields, also gets field name
sb.Append("Species " + ": " + Dtable.Rows[0]["Species"].ToString() + "\n\n");
sb.Append("Strain : " + Dtable.Rows[0]["Strain"].ToString() + "\n\n");
sb.Append("Plasmid1 : " + Dtable.Rows[0]["Plasmid1"].ToString() + "\n\n");
sb.Append("Plasmid2 : " + Dtable.Rows[0]["Plasmid2"].ToString() + "\n\n");
sb.Append("Insert1 : " + Dtable.Rows[0]["Insert1"].ToString() + "\n\n");
sb.Append("Insert2 : " + Dtable.Rows[0]["Insert2"].ToString() + "\n\n");
sb.Append("Modifications : " + Dtable.Rows[0]["Modifications"].ToString() + "\n\n");
sb.Append("Restrictions : " + Dtable.Rows[0]["Restrictions"].ToString() + "\n\n");
sb.Append("Mutation " + ": " + Dtable.Rows[0]["Mutation"].ToString() + "\n\n");
sb.Append("Antibiotic Resistance " + ": " + Dtable.Rows[0]["Antibiotic_Resistance"].ToString() + "\n\n");
//sb.Append("Growth Conditions " + ": " + Dtable.Rows[0]["Growth_Conditions"].ToString() + "\n\n");
sb.Append("Growth_Conditions :\n");
sb.Append(Dtable.Rows[0]["Growth_Conditions"].ToString() + "\n\n");
sb.Append("Others " + ": " + Dtable.Rows[0]["Others"].ToString() + "\n\n");
sb.Append("Genotype " + ": " + Dtable.Rows[0]["Genotype"].ToString() + "\n\n");
sb.Append("Risk Group " + ": " + Dtable.Rows[0]["Risk_Group"].ToString() + "\n\n");
sb.Append("Source generatedby" + ": " + Dtable.Rows[0]["Source_generatedby"].ToString() + "\n\n");
sb.Append("Source deliveredby " + ": " + Dtable.Rows[0]["Source_deliveredby"].ToString() + "\n\n");
sb.Append("Acheivedby " + ": " + Dtable.Rows[0]["Acheivedby"].ToString() + "\n\n");
sb.Append("Date " + ": " + Dtable.Rows[0]["Clone_Date"].ToString() + "\n\n");
sb.Append("Box " + ": " + Dtable.Rows[0]["Box"].ToString() + "\n\n");
// place stringbuilder in string reader
stringToPrint = new StringReader(sb.ToString());
// set font and size here
printFont = new Font("Arial", 12);
PrintDocument doc = new PrintDocument();
// set the printer name
//PrinterSettings.StringCollection Sc = PrinterSettings.InstalledPrinters;
doc.PrinterSettings.PrinterName = doc.PrinterSettings.PrinterName;
// add print page event handler
doc.PrintPage += new PrintPageEventHandler(doc_PrintPage);
// print the page
doc.Print();
// adds status to querystring
}
catch
{
}
finally
{
stringToPrint.Close();
}
// redirects to result.aspx
//RNDprintdetails.DataSource = Dtable;
//RNDprintdetails.DataBind();
//ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "MyFun1", "printDiv('rndListPrint');", true);
}
}
}
}
先谢谢。
Thanks in Advance.
推荐答案
您需要对打印页面处理程序(doc_PrintPage)进行编码以打印当前数据页并设置
You need to code the print page handler (doc_PrintPage) to print the current page of data and to set
e.HasMorePages = True
如果还有一些数据需要打印。
建议你阅读文章绝对新手的.NET打印指南 [ ^ ]开头。
if there is still some data to print.
Suggest you read the article An absolute beginner's guide to printing in .NET[^] to start with.
上面的查询是绝对正确的。这是客户端打印机的问题。
谢谢大家。
The above Query Is absolutely right. It was the issue of the client printer.
Thanks all of you.
这篇关于如何使用复选框打印多个页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文