无法选择子报告-.rdlc-VS 2010 [英] could not select subreport - .rdlc - VS 2010

查看:98
本文介绍了无法选择子报告-.rdlc-VS 2010的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在VS 2008中创建了许多报告.现在从VS 2010开始满足新要求.请注意,我正在使用.rdlc报告

I had created many reports with VS 2008. Now starting with VS 2010 for new requirement. Please note I am using .rdlc report

  • 我可以将子报表控件添加到报表中,但是无法选择可用的报表.没有浏览按钮或下拉菜单来选择可用的.rdlc报告.

  • I could add subreport control to the report but could not select the available reports. There is no browse button or a dropdown to choose the available .rdlc report.

当我手动输入报告名称时,reportviewer不会显示任何子报告.我也没有在输出"窗口中看到任何错误消息.

When I manually type the report name, the reportviewer doesnt show up any subreport. I dont see any error message on the 'Output' window either.

如何在VS 2010中使用子报表?我有什么想念的吗?感谢您的帮助.

How do I use subreport with VS 2010? Am I missing anything? Any help is appreciated.

我在同一台PC上安装了SQL 2005/2008(安装了报表服务),VS 2008,VS 2010.

I have SQL 2005/2008 (report services installed), VS 2008, VS 2010 installed on the same PC.

推荐答案

首先从工具箱中选择子报表,然后将其放置在要显示的位置.
现在,右键单击子报表属性,然后键入您的子报表名称.

First select sub report from Toolbox and put where you want to show.See the image bellow
Now right click on sub report properties and type your sub report name .

现在,您必须在.cs文件中创建一个子报告甚至处理程序,从那里像这样加载报告:

Now You have to create a sub report even handler in your .cs file from where you load your report like that:

public Ctor()
{
    string path = HttpContext.Current.Server.MapPath("Your Report path");
    ReportViewer1.Reset(); //important
    ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local;
    ReportViewer1.LocalReport.SubreportProcessing += Process_Subreport;
    LocalReport objReport = ReportViewer1.LocalReport;
    objReport.ReportPath = path;

    // Add Parameter If you need 
    List<ReportParameter> parameters = new List<ReportParameter>();
    parameters.Add(new ReportParameter("Name", Value));
    ReportViewer1.LocalReport.SetParameters(parameters);
    ReportViewer1.ShowParameterPrompts = false;
    ReportViewer1.ShowPromptAreaButton = false;
    ReportViewer1.LocalReport.Refresh();

    //Add Datasourdce
    ReportDataSource reportDataSource = new ReportDataSource();
    reportDataSource.Name = "Datasource Name Used due to report design";
    reportDataSource.Value = DataSourceValue;
    objReport.DataSources.Add(reportDataSource);
    objReport.Refresh();
}

现在创建偶数处理程序方法以加载子报表的详细信息.

Now Create Even Handler Method to load sub report details.

private void Process_Subreport(object sender, SubreportProcessingEventArgs e)
{
  //You can get parameter from main report 
  int paramname = int.Parse(e.Parameters[0].Values[0].ToString());
  //You can also add parameter in sub report if you  need like main report

  //Now add sub report data source     
   e.DataSources.Add(new ReportDataSource("DataSource Name",DataSourceValue)));
 }

我认为它将为您服务.谢谢.

I think it will be works for you.Thank you.

这篇关于无法选择子报告-.rdlc-VS 2010的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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