This is a migrated thread and some comments may be shown as answers.

Binding to Business Object

2 Answers 441 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Brad Perniciaro
Top achievements
Rank 1
Brad Perniciaro asked on 04 Jan 2008, 04:12 PM
I'm a bit confused about how to bind my report to a business object.  I've been able to get my object into the 'DataSource' property of my report, but I would think that at this point I'd have to specify the method which is responsible for populating the DataSource.  However, I'm not sure where to specify this method?  My business object is listed below, it is relatively simple and I'm currently just creating some debug objects in a method that will eventually pull from the database:

Imports System  
Imports System.Data  
Imports System.Configuration  
Imports System.Web  
Imports System.Collections  
Imports System.Collections.Generic  
Imports Triton.TCNext.EntityLayer  
 
Public Class TransactionType_BAL  
  Inherits List(Of TransactionType_BAL)  
 
  Sub New(ByVal id As Integer, ByVal name As String, ByVal description As String)  
    Me.ID = id 
    Me.Name = name 
    Me.Description = description 
  End Sub  
 
  Sub New()  
 
  End Sub  
 
  Private _id As Integer = 0 
  Public Property ID()  
    Get  
      Return _id  
    End Get  
    Set(ByVal value)  
      _id = value 
    End Set  
  End Property  
 
  Private _name As String = 0 
  Public Property Name()  
    Get  
      Return _name  
    End Get  
    Set(ByVal value)  
      _name = value 
    End Set  
  End Property  
 
  Private _description As String = 0 
  Public Property Description()  
    Get  
      Return _description  
    End Get  
    Set(ByVal value)  
      _description = value 
    End Set  
  End Property  
 
 
  Public Shared Function GetTransactionTypes() As List(Of TransactionType_BAL)  
    Dim transactionType1 As TransactionType_BAL = New TransactionType_BAL(1, "Checking Withdrawal", String.Empty)  
    Dim transactionType2 As TransactionType_BAL = New TransactionType_BAL(2, "Savings Withdrawal", String.Empty)  
    Dim transactionType3 As TransactionType_BAL = New TransactionType_BAL(3, "Credit Withdrawal", String.Empty)  
    Dim transactionTypes As List(Of TransactionType_BAL) = New List(Of TransactionType_BAL)  
    transactionTypes.Add(transactionType1)  
    transactionTypes.Add(transactionType2)  
    transactionTypes.Add(transactionType3)  
    Return transactionTypes  
  End Function  
 
  Private Shared Function GetTransactionTypeFromTransactionTypeEntity(ByVal transactionType As TransactionTypeEntity) As TransactionType_BAL  
    If transactionType Is Nothing Then  
      Return Nothing  
    Else  
      Return New TransactionType_BAL(transactionType.ID, transactionType.Name, transactionType.Description)  
    End If  
  End Function  
 
 
  Private Shared Function GetTransactionTypeListFromTransactionTypeEntityList(ByVal recordSet As List(Of TransactionTypeEntity)) As List(Of TransactionType_BAL)  
    Dim transactionTypes As List(Of TransactionType_BAL) = New List(Of TransactionType_BAL)  
    Dim record As TransactionTypeEntity  
    For Each record In recordSet  
      transactionTypes.Add(GetTransactionTypeFromTransactionTypeEntity(record))  
    Next  
    Return transactionTypes  
  End Function  
 
 
 
 
End Class  
 

My initial approach was to create a BLL, a DLL, entity objects to pass between the two, then implement stored procedures in the DB.  My thought was that I would have a method in my BLL that would populate a collection of objects then pass this collection to the report for display.  To populate the collection, the BLL would call a method in the DAL which in turn would populate an entity object (or collection of entity objects) based on the data retrieved through the utilization of stored procedures in the database.  The BLL would then convert these entity objects to business objects which could be passed to the report in a strongly-typed collection.

Does this approach seem feasible?  Is this overkill? 

2 Answers, 1 is accepted

Sort by
0
Svetoslav
Telerik team
answered on 07 Jan 2008, 10:51 AM
Hello Brad Perniciaro,

It is up to you what object to use as a data source for the report and how to fill it with data. The only thing you have to keep in mind is that the data should be available before you pass the report to the report viewer (or in case you render the report programmatically before calling the ReportProcessor.Render() method). The best place to do this is in your report's constructor right after the InitializeComponent() method. For example you can examine the code of any of the sample reports. Here is the constructor of the LetterReport:

Partial Public Class LetterReport 
    Inherits Report 
 
    Public Sub New() 
        ''' <summary> 
        ''' Required for Telerik Reporting Designer support 
        ''' </summary> 
        InitializeComponent() 
 
 
        'TODO: This line of code loads data into the 'LetterReportDataSet.LetterReportDataSetTable' table. You can move, or remove it, as needed. 
        Me.LetterReportDataSetTableAdapter1.Fill(Me.LetterReportDataSet.LetterReportDataSetTable) 
    End Sub 
End Class 

Best wishes,
Svetoslav
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Bhushan
Top achievements
Rank 1
answered on 20 Sep 2012, 10:21 AM
Hello ,
How to bind business object to the report , I want to pass the parameters to filter the data(List ) from database. is it necessary to take any wizard for it and configure ?.
where to write the code 1) Report.VB (after initialization) 2) Report Viewer page (.aspx )....
Tags
General Discussions
Asked by
Brad Perniciaro
Top achievements
Rank 1
Answers by
Svetoslav
Telerik team
Bhushan
Top achievements
Rank 1
Share this question
or