Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Feb 23, 2012 11:49 AM by mou_inn
Feb 23, 2012 11:49 AM|LINK
i searched google to bind sub report from code behind. i got this link http://www.codedigest.com/Articles/ASPNET/373_Working_with_ReportViewer_Control_in_AspNet.aspx
i follow the full instruction to bind sub report from the code but does not work.
at last i could solve the problem. here is the code.
protected void btnSearch_Click(object sender, ImageClickEventArgs e)
myDataSet = GetDataSource();
ViewState["myDataSet"] = myDataSet;
ReportDataSource rptDataSource1 = new ReportDataSource("dsEOD_Main", myDataSet.Tables);
ReportDataSource rptDataSource2 = new ReportDataSource("dsEOD_InfoByPerson", myDataSet.Tables);
ReportViewer1.ProcessingMode = ProcessingMode.Local;
ReportViewer1.LocalReport.ReportPath = "Report2.rdlc"; // "Report1.rdlc";
ReportViewer1.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(LocalReport_SubreportProcessing);
public void LocalReport_SubreportProcessing(object sender, SubreportProcessingEventArgs e)
string eParamName = e.Parameters["CountryCode"].Values.ToString();
myDataSet = ViewState["myDataSet"] as DataSet;
e.DataSources.Add(new ReportDataSource("dsEOD_InfoByPerson", myDataSet.Tables.Select("CountryCode='"+eParamName+"'").CopyToDataTable()));
i have some question please see the code in **protected void btnSearch_Click()**
i just need to know why do i need to bind two DataSources. why can't i bind one DataSources for master and another DataSources from **LocalReport_SubreportProcessing**
method. i want to bind one datatable first for master and want to bind another datatable for sub report from **LocalReport_SubreportProcessing** this function or event.
if i dont bind two datatable at a time then i am getting error for sub report. any solution if anyone knows then please share with me. thanks