关于从程序传递参数到水晶报表的子报表的问题,谢谢!
1.主报表和子报表都有一个参数,此参数在创建报表数据源时已经创建.主报表的参数名为:DepartmentCode,子报表的参数名为:Chiefi
2.主报表的参数我能够传,代码如下:
-------------------------------
private void ConfigurCrystalReports()
{
ReportDocument myReportDoc = new ReportDocument();
string reportPath = Server.MapPath( "../Reports/rp_Total.rpt ");
myReportDoc.Load(reportPath);
TableLogOnInfo logonInfo = new TableLogOnInfo();
foreach(CrystalDecisions.CrystalReports.Engine.Table tb in myReportDoc.Database.Tables)
{
logonInfo = tb.LogOnInfo;
logonInfo.ConnectionInfo.ServerName = "TestServer ";
logonInfo.ConnectionInfo.DatabaseName = "TestDB ";
logonInfo.ConnectionInfo.UserID = "sa ";
logonInfo.ConnectionInfo.Password = "test ";
tb.ApplyLogOnInfo(logonInfo);
}
ParameterValues pvDepartmentID = new ParameterValues();
ParameterDiscreteValue pdDepartmentID = new ParameterDiscreteValue();
pdDepartmentID.Value = " '0000200027 ', '0000200028 ' ";
pvDepartmentID.Add(pdDepartmentID);
myReportDoc.DataDefinition.ParameterFields[ "DepartmentCode "].ApplyCurrentValues(pvDepartmentID);
myCrystalReportViewer.ReportSource = myReportDoc;
}
-------------------------------
3.问题:怎么给子报表的参数Chiefi传递参数呢?谢谢!
------解决方案--------------------更改子报表链接里面
可以设置参数
------解决方案--------------------myReportDoc.DataDefinition.ParameterFields[ "DepartmentCode "].ApplyCurrentValues(pvDepartmentID);//這是主報表的
myReportDoc.DataDefinition.ParameterFields[子報表字段名,子報表名].ApplyCurrentValues(......);//這是子報表的