realcoding
asked on
crystal reports- asp.net- load more than one report into the viewer
i have the below code that dynamically loads a .rpt file. the report is pulling from my proj management application and i want it to show multiple projects based on input from the user...
on the webform UI i have controls that will allow me to eitehr get a list of project id values or i can generate a dataset or stored proc to get the desired project id values... lets say projectID = 1 and projectID = 2.
so i want the report to take these projectID values and show the report for both using the next, first, last buttons to flip though each report in the resulting dataset (or how ever i pass the project id values to crystal)
on the webform UI i have controls that will allow me to eitehr get a list of project id values or i can generate a dataset or stored proc to get the desired project id values... lets say projectID = 1 and projectID = 2.
so i want the report to take these projectID values and show the report for both using the next, first, last buttons to flip though each report in the resulting dataset (or how ever i pass the project id values to crystal)
ReportDocument rpt = new ReportDocument();
rpt.Load(Server.MapPath(strReportPath));
crvReport.ReportSource = rpt;
// Project Id Filter
ParameterValues myvals = new ParameterValues();
ParameterDiscreteValue myDiscrete = new ParameterDiscreteValue();
myDiscrete.Value = strSelectedProjects.ToString();
myvals.Add(myDiscrete); // this is "1,2,3"
rpt.DataDefinition.ParameterFields["ProjectId"].ApplyCurrentValues(myvals);
ConnectionInfo connectionInfo = new ConnectionInfo();
connectionInfo.DatabaseName = Global.GetDatabaseName();
connectionInfo.UserID = Global.GetUserID();
connectionInfo.Password = Global.GetPassword();
SetDBLogonForReport(connectionInfo, rpt);
private void SetDBLogonForReport(ConnectionInfo connectionInfo, ReportDocument reportDocument)
{
Tables tables = reportDocument.Database.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables)
{
TableLogOnInfo tableLogonInfo = table.LogOnInfo;
tableLogonInfo.ConnectionInfo = connectionInfo;
table.ApplyLogOnInfo(tableLogonInfo);
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Does the report show?
mlmcc