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.
public void LocalReport_SubreportProcessing(object sender, SubreportProcessingEventArgs e)
{
string eParamName = e.Parameters["CountryCode"].Values[0].ToString();
myDataSet = ViewState["myDataSet"] as DataSet;
e.DataSources.Add(new ReportDataSource("dsEOD_InfoByPerson", myDataSet.Tables[4].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
mou_inn
Participant
783 Points
964 Posts
SSRS report bind issue from code c# asp.net
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[0]);
ReportDataSource rptDataSource2 = new ReportDataSource("dsEOD_InfoByPerson", myDataSet.Tables[4]);
ReportViewer1.ProcessingMode = ProcessingMode.Local;
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(rptDataSource1);
ReportViewer1.LocalReport.DataSources.Add(rptDataSource2);
ReportViewer1.LocalReport.ReportPath = "Report2.rdlc"; // "Report1.rdlc";
ReportViewer1.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(LocalReport_SubreportProcessing);
ReportViewer1.LocalReport.Refresh();
}
public void LocalReport_SubreportProcessing(object sender, SubreportProcessingEventArgs e)
{
string eParamName = e.Parameters["CountryCode"].Values[0].ToString();
myDataSet = ViewState["myDataSet"] as DataSet;
e.DataSources.Add(new ReportDataSource("dsEOD_InfoByPerson", myDataSet.Tables[4].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