通过asp.net中的C#将参数传递给CRYSTAL REPORT
发布时间:2020-12-16 04:10:14 所属栏目:asp.Net 来源:网络整理
导读:我是水晶报告的新手.我按照这个链接 Crystal Report with SQL Stored Procedure Parameter and Visual Studio设计了水晶报告 实际上我需要将不同的ID(SP的输入值)传递给我与Crystal报表连接的SP. 这是我将ID传递给水晶报告的代码: protected void Button1_C
我是水晶报告的新手.我按照这个链接
Crystal Report with SQL Stored Procedure Parameter and Visual Studio设计了水晶报告
实际上我需要将不同的ID(SP的输入值)传递给我与Crystal报表连接的SP. 这是我将ID传递给水晶报告的代码: protected void Button1_Click(object sender,EventArgs e) { string QuotationID = ViewState["QUOTATION_ID"].ToString(); ReportDocument reportDocument = new ReportDocument(); ParameterField paramField = new ParameterField(); ParameterFields paramFields = new ParameterFields(); ParameterDiscreteValue paramDiscreteValue = new ParameterDiscreteValue(); paramField.Name = "@id"; paramDiscreteValue.Value = QuotationID; paramField.CurrentValues.Add(paramDiscreteValue); paramFields.Add(paramField); paramFields.Add(paramField); CrystalReportViewer1.ParameterFieldInfo = paramFields; string reportPath = Server.MapPath("~/CrystalReport.rpt"); reportDocument.Load(reportPath); CrystalReportViewer1.ReportSource = reportDocument; } 但是当我点击按钮时它会询问ID … 解决方法
要在水晶上设置参数,我总是这样做:
ReportDocument reportDocument = new ReportDocument(); reportDocument.Load(reportPath); reportDocument.SetParameterValue("@id",QuotationID); 如果您想将报告转换为pdf: var exportOptions = reportDocument.ExportOptions; exportOptions.ExportDestinationType = ExportDestinationType.NoDestination; exportOptions.ExportFormatType = ExportFormatType.PortableDocFormat; var req = new ExportRequestContext {ExportInfo = exportOptions}; var stream = reportDocument.FormatEngine.ExportToStream(req); 这将返回一个可以从aspx页面打开的文件流. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net-mvc – 实体框架数据库 – 第一个uniqueidentity结
- asp.net-mvc – 使用JWT实现的最小WebAPI2 OAuth:401始终返
- asp.net – 指定的CGI应用程序遇到错误,服务器终止进程
- asp.net-mvc – ASP.NET MVC提醒我旧的经典ASP意大利面条代
- Asp.net MVC中Razor常见的问题与解决方法总结
- asp.net-mvc – 如何在ASP.NET MVC中定义视图级变量?
- asp.net – UserControl有IsPostBack,但是Control没有
- asp.net-mvc – 如何从HttpContext访问ViewData? (ASP.Net
- asp.net-mvc – DesignPatterns:哪个最适合用于向导式用户
- asp.net-mvc – OWIN使用相同的MachineKey在ASP.NET MVC和W
推荐文章
站长推荐
- asp.net-mvc – MVC3 – 由几个控制器使用的Help
- asp.net-mvc – 在ASP.Net MVC 2中为非归因模型验
- asp.net-mvc-3 – 在DEBUG或Debugger中运行时禁用
- asp.net – 服务器端/客户端或两者用户输入验证
- asp.net-mvc – mvc asp.net中的自定义成员资格提
- asp.net-mvc – Asp.Net MVC3 RC Razor视图:在块
- asp.net – TeamCity可以使用sln2008构建运行程序
- asp.net-mvc – 在存储库之间调用方法 – 存储库
- asp.net-mvc-4 – DataAnnotation的必需属性
- asp.net-mvc – 密码保护整个.net mvc应用程序?
热点阅读