RDLC文件中的子报表 [英] Subreport in RDLC file

查看:127
本文介绍了RDLC文件中的子报表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在VS2010中生成报告时遇到一个问题.我正在使用RDLC.我的任务是生成一个报告,该报告应在报告的顶部显示客户详细信息,例如姓名,联系电话,电子邮件ID等.

I have one problem in generating Reports in VS2010. I am using RDLC. My task is to generate a report where it should show customer details like Name, Contact number, Email Id etc in the top portion of the report.

在正文部分,应显示列表保留详细信息.

In the body section it should show the list reservation details.

我的对象结构如下:

CustomerDetails:
        Name
        Age
        ContactNumber
        Email Id
        List<ReservationDetails>

ReservationDetails
        FromDate
        ToDate
        Period
        Amount

我不知道如何在子报表中呈现列表.它不是动态的,我在初始加载本身中获得了所有详细信息. 我将报告分为两个部分,首先(父级)是为了显示常见细节.子报表将显示预留"详细信息列表.

I do not know how to render the List in subreport. It is not dynamic and I got all the details in initial load itself. I split the report into tow section, First (parent) is to show the common details. and Subreport is to show the list of Reservation details.

推荐答案

1-创建主报表,该报表通过传递数据集"Customers"来显示客户详细信息.
2-添加新的报告"rptCustomerReservation"
3-添加通过使用参数CustomerID
返回List的数据集 4-在主报告中,选择要在其中添加报告的单元格,然后插入->子报告
5-转到子报告"属性,在名称中添加rptCustomerReservation,然后将报告用作子报告字段.
6-选择文件rptCustomerReservation",在报表数据"窗口中,右键单击添加参数",单击添加参数".输入类型ineger.并命名.
7-进入主报表并右键单击子报表,转到属性,单击参数"选项卡,指定相同的参数名称,然后从数据集下拉列表中选择参数值.
8-在cs文件中添加以下代码进行注册,并在页面加载中添加事件以添加子报告.

1- Create your Main report that show the customer details as you reauired by passing dataset "Customers"
2- Add a new Report "rptCustomerReservation"
3- Add dataset that returns List by taking a parameter CustomerID
4- In main report , select a cell where you want to add a report, insert -> Sub report
5- Go to Sub Report properties add rptCustomerReservation in name and use report as sub report fields.
6- Select File rptCustomerReservation, in Report data window,right click on Add Prameter, Click Add parameter. Give type ineger. and give name.
7- Go in to main report and right click sub report,go to properties, click parameters tab, give same parameter name and select parameter value from dataset dropdown.
8- Add following code in cs file to register and event to add sub report in page load.

public Ctor()
{
    rptViewer.LocalReport.SubreportProcessing += LocalReport_SubreportProcessing);
}   

void LocalReport_SubreportProcessing(object sender, SubreportProcessingEventArgs e)
{
    List<CATALOG_ITEM_DETAIL> DTCatalogItemDetail;
    if (e.ReportPath == "CatalogItemListItemDetails")
    {
        DTCatalogItemDetail = report.GetCatalogItemDetail(Convert.ToInt32(e.Parameters[0].Values[0]));
        ReportDataSource ds = new ReportDataSource("dsItemDetails", DTCatalogItemDetail);
        e.DataSources.Add(ds);    
      }
  }

这篇关于RDLC文件中的子报表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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