我在子报告中获取数据时遇到了一些问题。在水晶报表中以正确的方式获取数据,但是当我单击子报表时,它显示“没有可用的有效报表源”
protected void btnSearch_Click(object sender, EventArgs e)
{
ReportDocument rptDoc = new ReportDocument();
ComplaintTrackingSystem.Reports.Datas dss = new Reports.Datas();
DataTable dt = new DataTable();
// Just set the name of data table
DataSet ds;
Hashtable ObjParameters = new Hashtable();
BusinessLogicLayer ObjBusiness = new BusinessLogicLayer();
ObjParameters.Add("@From", dateFrom.SelectedDate.ToShortDateString());
ObjParameters.Add("@To", dateTo.SelectedDate.ToShortDateString());
ds = ObjBusiness.SPDataSet(ObjParameters, "ReportForAverageCompt");
dt.TableName = "Crystal Report Example";
dt = ds.Tables[0]; //This function is located below this function
dss.Tables[0].Merge(dt);
// Your .rpt file path will be below
rptDoc.Load(HttpContext.Current.Server.MapPath("../Reports/AverageReport.rpt"));
//set dataset to the report viewer.
rptDoc.SetDataSource(dss);
CrystalReportViewer1.ReportSource = rptDoc;
Session["Report"] = rptDoc;
ComplaintTrackingSystem.Reports.Datas dssNew = new Reports.Datas();
ds.Clear();
ds = ObjBusiness.SPDataSet(ObjParameters, "ReportForResolvedCompt");
dt.TableName = "Crystal Report";
dt = ds.Tables[0]; //This function is located below this function
dssNew.Tables[0].Merge(dt);
//set dataset to the report viewer.
rptDoc.Subreports["AdminReport.rpt"].SetDataSource(dssNew);
rptDoc.Refresh();
CrystalReportViewer1.ReportSource = rptDoc;
}