[英]Crystal report and parameter through querystring
This is in my html: 这是在我的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? 任何想法,我怎么能使这个工作?
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;
}
Try this: 尝试这个:
CrystalReportViewer1.ReportDocument.SetParameterValue("PO", Request.QueryString["po"]);
CrystalReportViewer1.ReportDocument.SetParameterValue("MR", Request.QueryString["mr"]);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.