ASP.NET怎样传参数到水晶报表里面的子报表?在线等!
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传递参数呢?谢谢!
PS:这是第二个账号发的同一条问题,都是100分.大家帮帮忙.总共有200分!谢谢!
------解决方案--------------------myReportDoc.DataDefinition.ParameterFields[ "DepartmentCode "].ApplyCurrentValues(pvDepartmentID);//這是主報表的
myReportDoc.DataDefinition.ParameterFields[子報表字段名,子報表名].ApplyCurrentValues(......);//這是子報表的
可以這樣定義:
ParameterFieldDefinitions parameterFieldDefinitions = reportDocument.DataDefinition.ParameterFields;
ParameterFieldDefinition parameterFieldDefinition = parameterFieldDefinitions[SUBREPORT_PARAMETER_FIELD_NAME, SUBREPORT_NAME];
------解决方案--------------------只给主报表用程序传过,子报表都是通过主报表传参过去。
LS那位能解决么?不能的话就用主报表向子报表传参,不就是多给主报表传个参数而已么