Reputation: 99
This is in my html:
<CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="true" />
and this is the load code:
ReportDocument cryRpt = new ReportDocument();
cryRpt.Load(Server.MapPath("/reports/Mat-new.rpt"));
cryRpt.SetParameterValue("PO", Request.QueryString["po"]);
cryRpt.SetParameterValue("MR", Request.QueryString["mr"]);
CrystalReportViewer1.ReportSource = cryRpt;
CrystalReportViewer1.RefreshReport();
var mytableloginfos = new TableLogOnInfos();
var myConnectionInfo = new ConnectionInfo();
mytableloginfos = CrystalReportViewer1.LogOnInfo;
foreach (TableLogOnInfo myTableLogOnInfo in mytableloginfos)
{
myTableLogOnInfo.ConnectionInfo = myConnectionInfo;
}
myConnectionInfo.ServerName = "opl";
myConnectionInfo.DatabaseName = "FIL";
myConnectionInfo.UserID = "rep";
myConnectionInfo.Password = "rep";
For the life of my, cant get the parameters to pass. Any idea how i can get this working?
Upvotes: 1
Views: 638
Reputation: 12731
Try this:
private void PassParameters()
{
string po = Request.QueryString["po"];
string mr = Request.QueryString["mr"]
ParameterValues ppo = new ParameterValues();
ParameterValues pmr = new ParameterValues();
ppo.AddValue(po);
pmr.AddValue(mr);
foreach (ParameterField field in cryRpt.ParameterFields)
{
if (string.Compare(field.Name.TrimStart('@'), "PO", true) == 0)
field.CurrentValues = ppo;
if (string.Compare(field.Name.TrimStart('@'), "MR", true) == 0)
field.CurrentValues = pmr;
}
Upvotes: 2
Reputation: 3009
Try this:
CrystalReportViewer1.ReportDocument.SetParameterValue("PO", Request.QueryString["po"]);
CrystalReportViewer1.ReportDocument.SetParameterValue("MR", Request.QueryString["mr"]);
Upvotes: 0