Rdlc SubReport issue, Cant use the List(of Object) Property from objectdatasource in report or subreport
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
Branc开发者_开发问答h2 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.
精彩评论