Last post Aug 26, 2011 10:12 AM by timothychimento
Jan 19, 2011 02:22 PM|GoLive|LINK
I am trying to create a report using crystal report 11 and asp.net 2.0(C#) and Oracle10g.
My requirement is to create a report which contains 6 pages with each pages different and is connected to different datasource. I pass three parameter (1)USER_ID, (II)YEAR and (III)TYPE. Based on these parament i'd like to construct a report with different
layout on different pages with different datasource.
Can i do it in single .rpt file or do i need to nested with sub reports. I am trying to create 6 subreports with their own datasource and put it in one parent report to display data, but not able to do it.
Please suggest me your valuable comments.
C# Crystal Report to pdf
C# Crystal Repor asp.net
Jan 24, 2011 04:46 AM|abrly|LINK
you can do it in single .rpt file which has one main report and number of sub reports nested.
have a look at my code how i am supplying different dataset as different data sources for the main report and sub reports...
Dim iInvoiceNo As Integer
iInvoiceNo = CType(Request.QueryString("InvoiceNo"), Integer)
Dim Disport As New ReportDocument
CrvInvoice.ReportSource = Disport
CrvInvoice.DisplayToolbar = True
CrvInvoice.HasPrintButton = True
CrvInvoice.HasExportButton = True
it is the working code.. let me know if you need my further assistance...
Jan 24, 2011 05:16 PM|GoLive|LINK
private void test_report()
string strReportPath = Server.MapPath("~\\Report\\OverallReport.rpt");
// Create Main Report DataTable
DataTable vDT = new DataTable();
DataColumn No = vDT.Columns.Add("No", typeof(System.String));
DataColumn Rating = vDT.Columns.Add("Rating", typeof(System.String));
DataColumn Value = vDT.Columns.Add("Value", typeof(System.Int16));
DataColumn Weight = vDT.Columns.Add("Weight", typeof(System.String));
DataColumn TotalValue = vDT.Columns.Add("TotalValue", typeof(System.Int16));
vDT.Rows.Add("TEST 1", "TEST 2", 1, "TEST 3", 100); // Test Data
// End Creating LE DataTable
// Create subReport DataTable
DataTable _vDT = new DataTable();
DataColumn _No = _vDT.Columns.Add("No", typeof(System.String));
DataColumn _Rating = _vDT.Columns.Add("Rating", typeof(System.String));
DataColumn _Value = _vDT.Columns.Add("Value", typeof(System.Int16));
DataColumn _Weight = _vDT.Columns.Add("Weight", typeof(System.Int16));
DataColumn _TotalValue = _vDT.Columns.Add("TotalValue", typeof(System.Int16));
// end creating virtual dataTable
CrystalReportViewer1.ReportSource = objRpt;
CrystalReportViewer1.DisplayToolbar = true;
CrystalReportViewer1.HasPrintButton = true;
CrystalReportViewer1.HasExportButton = true;
Thanks for your reply.
I tried following you code. But couldn't go through further because of this error.
System.NullReferenceException: Object reference not set to an instance of an object.
I put the correct name of the subreport and bind it to dataTable, but still showing null exception.
Here's the code. Please let me know where i am wrong.
Also. I put my subreport inside Detail Section of Main Report. Do i need to place in any other sections of the report?
Aug 26, 2011 10:12 AM|timothychimento|LINK
Thanks...after a week of searching how to do this your solution worked for me!