如何在Crystal Reports中将代码中的字符串报表名称添加到参数中 [英] How Can I Add String Report Name From Code To Parameter In Crystal Reports

查看:91
本文介绍了如何在Crystal Reports中将代码中的字符串报表名称添加到参数中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  public  ActionResult PatronLocationGraph()
{
var rpt = new Services.Report.ReportService( PatronLocationGraph null );
var service = new PatronService(DataContext);

// rpt.ReportDocument.ParameterFields.Add(所有顾客的饼图按位置);
// 我在这里分配但是我错过了参数Exception
var vms = service.GetGroupByLocation();
rpt.ReportDocument.SetDataSource(vms);

return ReturnPDF(rpt.GetPDFStream(), PatronLocationGraph);
}







我已经在报表设计器和字段中添加了一个文本框资源管理器添加新参数将其命名为ReportLabel并拖放此参数现在我正在分配报告标签但是获取缺少参数异常

解决方案

设置参数值后设置数据源

  var  vms = service.GetGroupByLocation(); 
rpt.ReportDocument.SetDataSource(vms);
rpt.ReportDocument.SetParameterValue( ReportName 报告名称....);
return ReturnPDF(rpt.GetPDFStream(), PatronLocationGraph);


public ActionResult PatronLocationGraph()
{
  var rpt = new Services.Report.ReportService("PatronLocationGraph", null);
  var service = new PatronService(DataContext);

  //rpt.ReportDocument.ParameterFields.Add("Pie Chart for All Patrons By Location");
  //Here i am assigning it but i am getting missing parameter Exception
  var vms = service.GetGroupByLocation();
  rpt.ReportDocument.SetDataSource(vms);

  return ReturnPDF(rpt.GetPDFStream(), "PatronLocationGraph");
}




I have already added a text box in the Report Designer and in Field Explorer added New Parameter Named it "ReportLabel" and drag and drop this Parameter now i am assigning the Report Label but getting Missing Parameter Exception

解决方案

set the parameter value after you set the datasource

var vms = service.GetGroupByLocation();
rpt.ReportDocument.SetDataSource(vms);
rpt.ReportDocument.SetParameterValue("ReportName", "Report Name ....");
return ReturnPDF(rpt.GetPDFStream(), "PatronLocationGraph");


这篇关于如何在Crystal Reports中将代码中的字符串报表名称添加到参数中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆