Print Page | Close Window

crystal report asp.net 2.0 C#

Printed From: Crystal Reports Book
Category: Crystal Reports for Visual Studio 2005 and Newer
Forum Name: Data Connectivity
Forum Discription: How to connect to data sources and export reports
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=4825
Printed Date: 18 May 2024 at 12:47pm


Topic: crystal report asp.net 2.0 C#
Posted By: vyasdipti
Subject: crystal report asp.net 2.0 C#
Date Posted: 17 Nov 2008 at 10:27pm
Since yesterday i got stuck up with this problem.
 
I want to show the report of Customer caste wise. In database i have tables like (1) tblcaste (2) tblcustomer. In tblcustomer i have casteid which is primary key of tblcaste.
 
In aspx page there is one dropdown box having various caste. User will select any one caste and click on button show report. Then report will be shown that following are the customer of this caste.
 
I could get the selected item of dropdown box in a variable. Also, without any programming through wizard i m able to see the report. But i m unable to pass the value of dropdown box to a report. Please note that my report page and my dropdown page is same. On click of button show report i m making report visible.
 
 
 
FYI, I m using asp.net 2.0 and C# as code behind language.


-------------
dIPTI vYAS
Arete Technologies Pvt Ltd
Sr.Systems Analyst



Replies:
Posted By: BrianBischof
Date Posted: 18 Nov 2008 at 12:31am
No problem. In your report create a parameter for the Caste ID and then create a record selection formula that filters on it. Test it to make sure it works. In your code, after loading the report document into memory, pass the drop down's value to that parameter using the SetParameterValue() method of the ReportDocument object. Using pseudo-code, it would look like this:
myReport.SetParameterValue("paramname", var);
 
I have all this fully documented in Chapter 2 of my Crystal Reports Encyclopedia Vol 2 book. You can find out more about my books at http://www.amazon.com/exec/obidos/ASIN/097495361X/bischofsystem-20 - Amazon.com or reading the http://members.crystalreportsbook.com - Crystal Reports eBooks online.


-------------
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>


Posted By: vyasdipti
Date Posted: 18 Nov 2008 at 2:19am
THanks Brian.
 
But i have one doubt, what is 'var' in the bracket beside paramname. Becoz i tried that, but its giving error.
 
FYI, i have declared one string variable in which i m taking the value of dropdownbox like,
 
string abc = ddlcaste.selecteditem.tostring();
CrystalDecisions.CrystalReports.Engine.ReportDocument obj1 = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

obj1.Load("E:\\Projects\\Oberoi Finance\\Latest_oberoiProject-14-11\\Reports\\castereport.rpt");

obj1.SetParameterValue ("castename", var);

CrystalReportViewer1.ReportSource = obj1;

 

but here var is giving a compilation error. Please suggest.



-------------
dIPTI vYAS
Arete Technologies Pvt Ltd
Sr.Systems Analyst


Posted By: BrianBischof
Date Posted: 18 Nov 2008 at 9:02am
"var" is the variable name that holds the value from your dropdown list. In your sample code, you should change it to this:
 

obj1.SetParameterValue ("castename", abc);



-------------
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>



Print Page | Close Window