c# – Winform ReportViewer并为ServerReport正确设置参数
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了c# – Winform ReportViewer并为ServerReport正确设置参数,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2851字,纯文字阅读大概需要5分钟。
内容图文
我正在设置我在ReportViewer控件中显示的报表的参数,并且参数设置正确并且报表正在使用适当的参数运行,但是在ReportViewer顶部提供报表条件的实际控件不是选择.为什么在标准中没有选择正确的项目,即使报告使用我设置的标准正确运行?
ReportParameter month = new ReportParameter("month", "September 2011");
SsrsReportInfo reportInfo = new SsrsReportInfo("Summary", "http://server/ReportServer/", "/MyFolder/Summary", month);
this.reportViewer1.ServerReport.ReportPath = reportInfo.ReportPath;
this.reportViewer1.ServerReport.ReportServerUrl = new Uri(reportInfo.ReportServerUrl);
if (reportInfo.Parameters != null)
{
this.reportViewer1.ServerReport.SetParameters(reportInfo.Parameters);
}
this.reportViewer1.RefreshReport();
这是reportInfo类的代码:
/// <summary>
/// SSRS report information for report viewer.
/// </summary>
public class SsrsReportInfo
{
/// <summary>
/// Initializes a new instance of the <see cref="SsrsReportInfo"/> class.
/// </summary>
/// <param name="reportName">Name of the report.</param>
/// <param name="reportServerUrl">The report server URL.</param>
/// <param name="reportPath">The report path.</param>
public SsrsReportInfo(string reportName, string reportServerUrl, string reportPath)
: this(reportName, reportServerUrl, reportPath, null)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="SsrsReportInfo"/> class.
/// </summary>
/// <param name="reportName">Name of the report.</param>
/// <param name="reportServerUrl">The report server URL.</param>
/// <param name="reportPath">The report path.</param>
/// <param name="reportParameters">The report parameters.</param>
public SsrsReportInfo(string reportName, string reportServerUrl, string reportPath, params ReportParameter[] reportParameters)
{
this.ReportName = reportName;
this.ReportServerUrl = reportServerUrl;
this.ReportPath = reportPath;
this.Parameters = reportParameters;
}
/// <summary>
/// Gets or sets the name of the report.
/// </summary>
/// <value>The name of the report.</value>
public string ReportName
{
get;
set;
}
/// <summary>
/// Gets or sets the report server URL.
/// </summary>
/// <value>The report server URL.</value>
public string ReportServerUrl
{
get;
set;
}
/// <summary>
/// Gets or sets the report path.
/// </summary>
/// <value>The report path.</value>
public string ReportPath
{
get;
set;
}
/// <summary>
/// Gets or sets the parameters.
/// </summary>
/// <value>The parameters.</value>
public ReportParameter[] Parameters
{
get;
set;
}
}
谢谢,
标记
解决方法:
我在这里找到了问题.我有代码在Form构造函数中设置路径,URL,参数和刷新报表.我将它移动到Form.Load事件中,它现在工作正常.报告仍然正常运行,但现在参数也在ReportViewer顶部的标准部分中正确设置.
我在这里显示了相同的用法:http://technet.microsoft.com/es-es/library/aa337089(SQL.90).aspx,但是注意到他们在Form.Load事件中做了它,我尝试了它,并且它有效.我也许可以在ReportViewer.Load事件中执行此操作,原因可能是在设置值之前尚未在屏幕上绘制控件.
内容总结
以上是互联网集市为您收集整理的c# – Winform ReportViewer并为ServerReport正确设置参数全部内容,希望文章能够帮你解决c# – Winform ReportViewer并为ServerReport正确设置参数所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。