You need to place a "List" item in the Report body and then add your Tables within the List. If you open your RDLC in IE, the XML structure of the <Body> element of your RDLC would look something like
Thanks for ur rply but i m using RDLC my code is ReportDataSource dataSource = new ReportDataSource(); dataSource.Name = "DataSet12_AuditReport"; dataSource.Value = ds1.Tables[0]; string reportTitle = "AuditReport"; ReportViewer12.ServerReport.Refresh();
ReportViewer12.LocalReport.Refresh(); ReportViewer12.LocalReport.DataSources.Clear(); ReportViewer12.LocalReport.DataSources.Add(dataSource); ReportViewer12.LocalReport.ReportPath = Server.MapPath("../Reports/Report.rdlc"); ReportViewer12.LocalReport.DisplayName
= reportTitle; ReportViewer12.LocalReport.Refresh(); And in RDLC we can have only one datatable i hope u understand my point thankx in advance
Will u please explain it with some code. What i need to do with report viewer as i have two sub reports in RDLC. and both the sub reports are using different tables say "Table1" and Table2", so now for first subreport
reportviewer.datasource = "Dataset1_Table1"
and for second it is "Dataset1_Table2"
but we can only assign one datasource to a report viewer
new
SubreportProcessingEventHandler(ItemsSubreportProcessingEventHandler);
//The above event will fire for each sub report included in ur RDLC, u just need to supply datasorce according to ur sub report
public
void ItemsSubreportProcessingEventHandler(object sender,
SubreportProcessingEventArgs e)
{
switch (e.ReportPath)
{
case "CarrierDistributionReport":
objCust._CustomerID =
Convert.ToInt32(hfCustomerId1.Value);
DataSet ds1 =
new DataSet();
ds1 = objCust.AuditReport();
ReportDataSource dataSource =
new ReportDataSource();dataSource.Name =
"DataSet12_AuditReport";
dataSource.Value = ds1.Tables[0];
e.DataSources.Add(
new
ReportDataSource("DataSet12_AuditReport", ds1.Tables[0]));
break;
case "CostPerUserReport":
objCust._CustomerID = Convert.ToInt32(hfCustomerId1.Value);ds1 =
new DataSet();
ds1 = objCust.Get_CostPerUser();
dataSource =
new
ReportDataSource();
dataSource.Name = "DataSet11_Get_CostPerUser";
dataSource.Value = ds1.Tables[0];
e.DataSources.Add(new
ReportDataSource("DataSet11_Get_CostPerUser", ds1.Tables[0]));
break;
case "PlanAndMinuteReport":
objCust._CustomerID =
Convert.ToInt32(hfCustomerId1.Value);
ds1 = new DataSet();
ds1 = objCust.Get_CostPerUser();
dataSource = new
ReportDataSource();dataSource.Name =
"DataSet12_AuditReport";
dataSource.Value = ds1.Tables[0];
e.DataSources.Add(
new
ReportDataSource("DataSet12_AuditReport", ds1.Tables[0]));
break;
default:
break;
}
}
I hope this sollution will help others too
Thanks all for ur help
</p>
Anil
Marked as answer by anildbest83 on Apr 03, 2008 01:01 PM
anildbest83
Member
32 Points
57 Posts
Use Multiple Tables in RDLC
Apr 02, 2008 09:39 AM|LINK
I need to use two sub reports in single rdlc
How we can do this with single report viewer or whatever
Pls rply
vivekjdesai
Member
506 Points
68 Posts
Re: Use Multiple Tables in RDLC
Apr 02, 2008 10:43 AM|LINK
You need to place a "List" item in the Report body and then add your Tables within the List. If you open your RDLC in IE, the XML structure of the <Body> element of your RDLC would look something like
<Body> <ReportItems> <List Name ="list1"> <KeepTogether>True</KeepTogether> <ReportItems> <Table Name="Table1"> .... </Table> <Table Name="Table2"> .... </Table> </ReportItems> </List> </ReportItems> </Body><div class=c style="MARGIN-LEFT: 1em; TEXT-INDENT: -2em"> </div>anildbest83
Member
32 Points
57 Posts
Re: Use Multiple Tables in RDLC
Apr 02, 2008 11:12 AM|LINK
Thanks for ur rply but i m using RDLC my code is ReportDataSource dataSource = new ReportDataSource(); dataSource.Name = "DataSet12_AuditReport"; dataSource.Value = ds1.Tables[0]; string reportTitle = "AuditReport"; ReportViewer12.ServerReport.Refresh(); ReportViewer12.LocalReport.Refresh(); ReportViewer12.LocalReport.DataSources.Clear(); ReportViewer12.LocalReport.DataSources.Add(dataSource); ReportViewer12.LocalReport.ReportPath = Server.MapPath("../Reports/Report.rdlc"); ReportViewer12.LocalReport.DisplayName = reportTitle; ReportViewer12.LocalReport.Refresh(); And in RDLC we can have only one datatable i hope u understand my point thankx in advance
anildbest83
Member
32 Points
57 Posts
Re: Use Multiple Tables in RDLC
Apr 02, 2008 11:16 AM|LINK
<p>
Thanks for ur rply but i m using RDLC
Please review th code below:
ReportDataSource dataSource = new ReportDataSource();
dataSource.Name = "DataSet12_AuditReport";
dataSource.Value = ds1.Tables[0];
string reportTitle = "AuditReport";
ReportViewer1.ServerReport.Refresh();
ReportViewer1.LocalReport.Refresh();
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(dataSource);
ReportViewer1.LocalReport.ReportPath = Server.MapPath("../Reports/Report.rdlc");
ReportViewer1.LocalReport.DisplayName = reportTitle;
ReportViewer1.LocalReport.Refresh();
And in RDLC we can have only one datatable
i hope u understand my point
thankx in advance
</p>
sasi.k
Participant
1547 Points
296 Posts
Re: Use Multiple Tables in RDLC
Apr 02, 2008 11:32 AM|LINK
Create a common View with the combination of both the tables and use the same in both master and subreports.
1. Apply the filters properly in subreport.
2. Dont forget to pass the same dataset to subreport too.
Please remember to click "Mark as Answer" on this post if it helped you.
anildbest83
Member
32 Points
57 Posts
Re: Use Multiple Tables in RDLC
Apr 02, 2008 02:44 PM|LINK
Sorry Sassi, ur point not clear to me.
Will u please explain it with some code. What i need to do with report viewer as i have two sub reports in RDLC. and both the sub reports are using different tables say "Table1" and Table2", so now for first subreport
reportviewer.datasource = "Dataset1_Table1"
and for second it is "Dataset1_Table2"
but we can only assign one datasource to a report viewer
i hope u understand my point
Pls rply soon
anildbest83
Member
32 Points
57 Posts
Re: Use Multiple Tables in RDLC
Apr 02, 2008 02:53 PM|LINK
I m using two sub reports in "Report1.rdlc" and these two sub reports using "Report2.rdlc" and Report3.rdlc" respectively
Now in the page i have Reportviewer1 for report "Report1.rdlc
Report1.rdlc is having dataset ds1_table1 and Report2.rdlc is having dataset ds2_table1
so how should i set repeortviewer datasource for "Report.rdlc" and for "Report3.rdlc"
as repeort viewer can have only one datasource name.
i hope u understand my point
pls rply soon
sasi.k
Participant
1547 Points
296 Posts
Re: Use Multiple Tables in RDLC
Apr 03, 2008 07:20 AM|LINK
yes you are right. but for subreports you have add in DrillthroughEventHandler .. Add an in evenhandler for ReportViewer in pageLoad as follows
// Add a handler for drillthroughReportViewer1.Drillthrough +=
new DrillthroughEventHandler(SubReport_DrillthroughEventHandler);// Drill through event handler for subreport processing.
void SubReport_DrillthroughEventHandler(object sender, DrillthroughEventArgs e){
LocalReport report = (LocalReport)e.Report; DataSet dsSubReport = GetSubReportData(); // The Second dataSet Or detailed Datasetreport.DataSources.Add(new ReportDataSource("AdventureWorksDataSet1_vEmployee", dsSubReport.Tables[0]));}
For Main Report you can pass as like as same .. in your Bind method or what ever you are trying already
localReport.DataSources.Add(
new ReportDataSource("AdventureWorksDataSet_vEmployeeDepartmentHistory", dsReport.Tables[0]));Hope it will work for you.
Please remember to click "Mark as Answer" on this post if it helped you.
anildbest83
Member
32 Points
57 Posts
Re: Use Multiple Tables in RDLC
Apr 03, 2008 01:00 PM|LINK
<p>Here is the solution
ReportDataSource
dataSource = new ReportDataSource(); string reportTitle = "AuditReport"; ReportViewer12.LocalReport.ReportPath = Server.MapPath("../Reports/Report.rdlc");ReportViewer12.LocalReport.DisplayName = reportTitle;
ReportViewer12.LocalReport.Refresh();
ReportViewer12.LocalReport.SubreportProcessing +=
new SubreportProcessingEventHandler(ItemsSubreportProcessingEventHandler);//The above event will fire for each sub report included in ur RDLC, u just need to supply datasorce according to ur sub report
public void ItemsSubreportProcessingEventHandler(object sender, SubreportProcessingEventArgs e){
switch (e.ReportPath){
case "CarrierDistributionReport":objCust._CustomerID =
Convert.ToInt32(hfCustomerId1.Value); DataSet ds1 = new DataSet();ds1 = objCust.AuditReport();
ReportDataSource dataSource = new ReportDataSource();dataSource.Name = "DataSet12_AuditReport";dataSource.Value = ds1.Tables[0];
e.DataSources.Add(
new ReportDataSource("DataSet12_AuditReport", ds1.Tables[0])); break; case "CostPerUserReport": objCust._CustomerID = Convert.ToInt32(hfCustomerId1.Value);ds1 = new DataSet();ds1 = objCust.Get_CostPerUser();
dataSource =
new ReportDataSource(); dataSource.Name = "DataSet11_Get_CostPerUser";dataSource.Value = ds1.Tables[0];
e.DataSources.Add(new ReportDataSource("DataSet11_Get_CostPerUser", ds1.Tables[0])); break; case "PlanAndMinuteReport":objCust._CustomerID =
Convert.ToInt32(hfCustomerId1.Value); ds1 = new DataSet();ds1 = objCust.Get_CostPerUser();
dataSource = new ReportDataSource();dataSource.Name = "DataSet12_AuditReport";dataSource.Value = ds1.Tables[0];
e.DataSources.Add(
new ReportDataSource("DataSet12_AuditReport", ds1.Tables[0])); break; default: break;}
}
I hope this sollution will help others too
Thanks all for ur help
</p>
ruwansj
Member
2 Points
1 Post
Re: Use Multiple Tables in RDLC
Jun 22, 2009 06:40 AM|LINK
Thanks Anil,
You solved my problem.