Akhter HUssain

Akhter HUssain

  • 712
  • 1.3k
  • 103.2k

Label print using crystal report in asp.net c#?

Aug 7 2019 1:29 PM
i want to print one report  multiple times on user input number of page to be print,  as like in this video....here is link of that video Https://www.youtube.com/watch?v=i7NYevleSA0  .
 
current;y i am printing one report on one page using crystal report ,,,,
here is my code 
  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Linq;  
  4. using System.Web;  
  5. using System.Web.UI;  
  6. using System.Web.UI.WebControls;  
  7. using System.Configuration;  
  8. using System.Data;  
  9. using System.Data.SqlClient;  
  10. using System.IO;  
  11. using System.Globalization;  
  12. using Microsoft;  
  13. using Salesorder;  
  14. using CrystalDecisions.CrystalReports.Engine;  
  15. using System.Drawing.Printing;  
  16. namespace Salesorder  
  17. {  
  18.     public partial class Print : System.Web.UI.Page  
  19.     {  
  20.         SqlConnection con = new SqlConnection();  
  21.         ReportDocument rpt = new ReportDocument();  
  22.         protected void Page_Load(object sender, EventArgs e)  
  23.         {  
  24.             //if (!IsPostBack)  
  25.             {  
  26.                 rpt.Dispose();  
  27.                 rpt.Close();  
  28.                 // loadReport();  
  29.             }  
  30.   
  31.   
  32.   
  33.         }  
  34.   
  35.         protected void Button1_Click(object sender, EventArgs e)  
  36.         {  
  37.             rpt.Dispose();  
  38.             rpt.Close();  
  39.             con = new SqlConnection("Data Source=DESKTOP-5PJ76B9;Integrated Security=SSPI;Initial Catalog=SilverProduction;MultipleActiveResultSets=True;");  
  40.             try  
  41.             {  
  42.                 con.Open();  
  43.                 SqlCommand cmd = new SqlCommand("spbigbaleprint", con);  
  44.                 cmd.CommandType = CommandType.StoredProcedure;  
  45.   
  46.                 // cmd.Parameters.AddWithValue("@BID", Request.QueryString["BID"]);  
  47.                 //  cmd.Parameters.AddWithValue("@BID", TextBox2.Text);  
  48.                 SqlDataAdapter adp = new SqlDataAdapter(cmd);  
  49.                 DataSet ds = new DataSet();  
  50.   
  51.   
  52.                 adp.Fill(ds);  
  53.                 //   for (int i = 0; i < int.Parse(TextBox1.Text); i++)  
  54.                 // {var dialog = new PrintDialog();  
  55.   
  56.   
  57.                 rpt.Load(Server.MapPath("~/CRBigbalprnt.rpt"));  
  58.                 rpt.SetDataSource(ds.Tables["Table"]);  
  59.   
  60.               //  PrintDocument pd = new PrintDocument();  
  61.               //  rpt.PrintOptions.PrinterName = pd.PrinterSettings.PrinterName;  
  62.   
  63.                 ReportDocument rd = new ReportDocument();  
  64.                 // rd.PrintToPrinter(Convert.ToInt32(TextBox1.Text.Trim()), false, 0, 0);  
  65.                 CrystalReportViewer1.ReportSource = rpt;  
  66.                 rpt.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Response, false"Bigbalprd");  
  67.   
  68.             }  
  69.   
  70.   
  71.             catch (Exception ex) { }  
  72.         }  
  73.   
  74.   
  75.   
  76.         protected void CRBigview_Unload(object sender, EventArgs e)  
  77.         {  
  78.   
  79.   
  80.             if (rpt != null)  
  81.             {  
  82.                 rpt.Close();  
  83.                 rpt.Dispose();  
  84.   
  85.             }  
  86.         }  
  87.   
  88.     }  
  89. }

Answers (4)