Rdlc 子报表问题,无法在报表或子报表中使用 objectdatasource 中的 List(of Object) 属性

发布于 2024-09-13 19:12:33 字数 1839 浏览 2 评论 0原文

我正在尝试使用对象数据源在 VB.net 2008 中创建 RDLC 报告。

问题是,我的对象数据源是 Item 对象的列表。 每个 Item 对象都有一个名为 Stock 的属性 - 它是 ItemStock 对象的列表。 这两个类的主要属性如下:

Item Class:
Name,Id, Stock,<and some other like MRP,Tax etc.>

ItemStock Class:
BranchId,BatchNo,Expirydate,StockQuantity

单个 Item 对象可以包含每个 BranchId 的多个 ItemStock 项目。因此,Item.Stock 属性将是此类库存商品的并集,即 List(of ItemStock)

现在,我的名为 Stock 报告的报告将有一个 List(of Item) 对象作为数据源(绑定源)。我得到了所需的对象列表,没有任何错误。 我将该列表分配给数据网格以显示分支聚合股票值。 也就是说:

Itemname         Branch1    Branch2   Branch2
item1               12         2         3

这工作正常,因为我已经使用 LINQ 通过处理 Cell_format 事件来获取每个分支中项目的库存值总和,

但是当我创建报告时,问题就出现了。我的报告需要采用以下格式:

Item1 Name
     Branch     BatchNo   Expiry      Quantity
     Branch1    12677     12/09/2009    56 
     Branch1    1217      04/04/2010    6 
     Branch2    22644     12/03/2011    16 
     Branch3    72600     12/02/2012    7 

Item2 Name
     Branch     BatchNo   Expiry       Quantity
     Branch1    2677     12/09/2009      5 
     Branch2    244      12/03/2011      1 
     Branch3    7200     12/02/2012      7 

现在我无法理解如何使用 Item 对象上的 Stock 属性来显示此报告。 我可以选择使用我创建的子报表。但我无法弄清楚如何在处理子报表时分配特定项目对象的库存属性。

我还尝试按如下方式处理 SubreportProcessing 事件:

  Private Sub SubreportProcessing(ByVal sender As Object, ByVal e As SubreportProcessingEventArgs)
        e.DataSources.Add(New ReportDataSource("Chemasis_BusinessObjects_Objects_ItemStock", ctype(itemBindingSource.Current,Item).Stock))
    End Sub  

但显然,这需要 ItemBindingSource 中的第一个项目,因此所有库存值都显示为相同的。

I am trying to create an RDLC report in VB.net 2008 using object datasource.

The thing is, my object datasource is a list of Item objects.
Each Item object has a property named Stock - which is a list of ItemStock objects.
The main properties of both classes are as follows:

Item Class:
Name,Id, Stock,<and some other like MRP,Tax etc.>

ItemStock Class:
BranchId,BatchNo,Expirydate,StockQuantity

A single Item object can contain a number of ItemStock items for each BranchId. The Item.Stock property will be therefore the union of such stock items, i.e. List( of ItemStock).

Now, my report named Stock report will have a List(of Item) object as a datasource(binding source). I get the required object list with no error at all.
I assign the list to a Datagrid to display branchwise aggregate stock values.
That is:

Itemname         Branch1    Branch2   Branch2
item1               12         2         3

This works fine, as I have used LINQ to get the sum of stock values for item in each branch, by handling the Cell_format event

But the problem arises when I create a report. My report needs to be in format:

Item1 Name
     Branch     BatchNo   Expiry      Quantity
     Branch1    12677     12/09/2009    56 
     Branch1    1217      04/04/2010    6 
     Branch2    22644     12/03/2011    16 
     Branch3    72600     12/02/2012    7 

Item2 Name
     Branch     BatchNo   Expiry       Quantity
     Branch1    2677     12/09/2009      5 
     Branch2    244      12/03/2011      1 
     Branch3    7200     12/02/2012      7 

Now I can't understand how to use the property Stock on an Item object to display this report.
I have an option of using a subreport, which I created. But I can not figure out how to assign the stock property of particular item object while processing the subreport.

I also tried handling SubreportProcessing event as follows:

  Private Sub SubreportProcessing(ByVal sender As Object, ByVal e As SubreportProcessingEventArgs)
        e.DataSources.Add(New ReportDataSource("Chemasis_BusinessObjects_Objects_ItemStock", ctype(itemBindingSource.Current,Item).Stock))
    End Sub  

But obviously, this takes the first item in ItemBindingSource and so, all the stock values are displayed as the same.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文