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); } } } }
e.HasMorePages = True
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)