Click here to Skip to main content
12,953,007 members (36,360 online)
Rate this:
 
Please Sign up or sign in to vote.
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
$ultaNn733
Updated 21-Jan-13 21:25pm
v2
Comments
onurag19 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 22-Jan-13 3:37am
   
plz clear your question little..
Lubnash 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 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 29-Jan-13 7:14am
   
i want to use data table instead of dataset
N Haque 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);
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 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 23-Jan-13 1:11am
   
give your crystal report name
Lubnash 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

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

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 6,389
CHill60 3,490
Maciej Los 3,103
Jochen Arndt 1,975
ppolymorphe 1,920


Advertise | Privacy | Mobile
Web02 | 2.8.170525.1 | Last Updated 22 Jan 2013
Copyright © CodeProject, 1999-2017
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