通过asp.net中的C#将参数传递给CRYSTAL REPORT
发布时间:2020-05-24 14:45:21 所属栏目:asp.Net 来源:互联网
导读:我是水晶报告的新手.我按照这个链接 Crystal Report with SQL Stored Procedure Parameter and Visual Studio设计了水晶报告 实际上我需要将不同的ID(SP的输入值)传递给我与Crystal报表连接的SP. 这是我将ID传递给水晶报告的代码: protected void Button1_Cl
|
我是水晶报告的新手.我按照这个链接
Crystal Report with SQL Stored Procedure Parameter and Visual Studio设计了水晶报告
这是我将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 – 为什么我不能从Visual Studio 2005安装IE8后调试
- asp.net-mvc – ASP.NET MVC – 用于ICollection的EditorTe
- asp.net – 如何将两个模型传递给一个View
- asp.net-mvc – Upshot.js的当前状态
- asp.net-mvc – 使用令牌认证访问Web Api的MVC .NET cookie
- 介绍几种 ADO.net 中的数据库连接方式
- asp.net – IIS 8.0中内核模式和用户模式缓存之间的区别
- asp.net-mvc – 在AccountController之外访问UserManager
- ASP.NET GridView SortedAscendingHeaderStyle不起作用
- asp.net – 元素’system.webServer’有无效的子元素’重写
推荐文章
站长推荐
- asp.net核心 – 如何排除在ASP.NET Core中发布文
- asp.net – MvcHtmlString.ToHtmlString()不编码
- asp.net-mvc – 单元测试我的控制器方法导致一个
- asp.net-core – 从显式类型的ASP.NET Core API控
- asp.net – 我可以同时拥有Controller和ApiContr
- asp.net-mvc – ASP.NET MVC现在是“开源”.这是
- asp.net核心 – 在ASP.NET核心应用程序中使用NLo
- asp.net-mvc – 使用与本地化更改冲突的自定义数
- 页面刷新导致ASP.NET应用程序中重复的POST
- 如何在ASP.NET MVC中创建CheckBoxListFor扩展方法
热点阅读
