Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# C#4.0 CrystalReports
i want to print crystal report using button click event how should do thi process with c#??
i am using webforms .
Posted 21-Jan-13 21:24pm
Lubnash816
Edited 21-Jan-13 21:25pm
v2
Comments
onurag19 at 22-Jan-13 3:26am
   
You do not want the crystal report to show the data. When you click on button it should print directly that is what you want ?
Gopal Rakhal at 22-Jan-13 3:37am
   
plz clear your question little..
Lubnash at 22-Jan-13 6:44am
   
i want to show the data frst then print with button click event
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

In your button clcik write below code.
 
crystalreport1 objReport1=new crystalreport1();
crystalreportviewer1.reportsource=objReport1;
  Permalink  
v2
Comments
Lubnash at 23-Jan-13 1:08am
   
its giving me this error on crystalreport1
The type or namespace name 'CrystalReport1' could not be found (are you missing a using directive or an assembly reference?)
josh-jw at 23-Jan-13 1:11am
   
give your crystal report name
Lubnash at 23-Jan-13 4:04am
   
protected void Print(object sender, EventArgs e)
{
CrystalReport objReport1 = new CrystalReport();
CrystalReportViewer1.ReportSource = objReport1;

}
 
The type or namespace name 'CrystalReport' could not be found (are you missing a using directive or an assembly reference?) C:\inetpub\wwwroot\Mreport\crystal.aspx.cs
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

try this way ...
 
 
ReportDocument oDocument = new ReportDocument();
oDocument.Load(Application.StartupPath + "//ReportPath//ReportName.rpt");
oDocument.SetDataSource(new DataSet()); // Added report data as dataset.
            
crviewer.ReportSource = oDocument;
crviewer.PrintReport();
 

  Permalink  
v2
Comments
Lubnash at 29-Jan-13 7:14am
   
i want to use data table instead of dataset
N Haque at 29-Jan-13 8:53am
   
you can try this-
DataTable dt = new DataTable();
// dt=Your DataTable;
DataSet ds = new DataSet();
ds.Tables.Add(dt);
oDocument.SetDataSource(ds);

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 686
1 OriginalGriff 345
2 CPallini 200
3 PIEBALDconsult 150
4 Magic Wonder 131
0 OriginalGriff 5,795
1 Sergey Alexandrovich Kryukov 5,028
2 CPallini 4,700
3 George Jonsson 3,142
4 Gihan Liyanage 2,450


Advertise | Privacy | Mobile
Web03 | 2.8.140916.1 | Last Updated 22 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100