You can click on Images to Enlarge
To start , Create a new website in VS and right click on Solution Explorer and select Add new Item > Crystal Report. In the wizard window choose Using the Report Wizard radio button and Standard type in Choose an Expert section.
In next screen select Expand OLEDB(ADO) and Choose create new connection
Select Microsoft OLEDB Provider for SQL server and click next
In next screen check the Integrated security checkbox so that report doesn't ask for username and password Enter you SQL Server name and Select DataBase from the dropdown ,
In next window expand and locate your tables you want to use and add them in right pane
In next screen select the fields you want to display in main report and add them in right pane , in my case i am showing fields from two tables in main report
Now select the field which you want report to be grouped by ( in this example i m grouping report by Project Name)
Select the report style you want and finish the wizard
Now to add a subReport Right click in group header section (below Group #1 Name)
Choose Insert > SubReport , Place the ractangle where you want SubReport to be displayed. a wizard window will open prompltly
Enter report Name and click on report wizard buttonin next screen ,
Choose the table and fields you want to use in SubReport in next two screens and click on finish
Now Insert subReport window will open again , In this window click on Link Tab and select the field on which you want to filter SubReport or the ID of the record to show SubReport. I am using ProjectID in this example.
This is how design of report will look like
And this is how report preview will look
Save , build and rum the website.
Now if you don't want to show SubReport but want to put a hyperlink instead or want to create On-Demand SubReport then do these changes in the design of report
Right click on SubReport in Design View and select Format Object
In the window opened ,Go to SubReport tab, Change the SubReport name to text you want to show as hyperlink, Check the On-demand SubReport check box and click on ok
Now design of report will look like image below
On default.aspx page drag CrystalReportViewer from toolbox and assign CrystalReport we just created as source
Html source will go like this (AutoGenerated)
<CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server"
AutoDataBind="True" Height="1039px"
ReportSourceID="CrystalReportSource1"
Width="901px" />
<CR:CrystalReportSource ID="CrystalReportSource1" runat="server">
<Report FileName="CrystalReport.rpt">
</Report>
</CR:CrystalReportSource>
Save, build and run the solution , this is how Crystal Report SubReport will look like
Hope this helps.
Other asp.net,C#,VB.NET articles:
13 comments:
gret
hi,
good post
I want ,how to convert Crystal Report to PDF and
Please Give Example for Cross Tab
your tutorial is very good.
this Post is really great help for someone is learn CR
Crystal Reports sucks!!!
do you have this tutorial in vb .net and mysql database?..
gfhf
i need use crystal sub report with more than stored procedure or more dataset use.
any one help me ?
good information about SuB reports in CR
your information was great very helpful but i have to export to excel and force a page break on every new sub-report (i have 6) any ideas on how to do this
pls send me the C# code to view report dynamically
Email: nazmulmunaz@gmail.com
Very very good
Super..
can u pls send a copy 2 my e-mail?
pinhoong@Hotmail.com
thx in advance
Post a Comment