Binding to Business Object

3 posts, 0 answers
  1. Brad Perniciaro
    Brad Perniciaro avatar
    45 posts
    Member since:
    Nov 2006

    Posted 04 Jan 2008 Link to this post

    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. Svetoslav
    Admin
    Svetoslav avatar
    649 posts

    Posted 07 Jan 2008 Link to this post

    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
  3. DevCraft banner
  4. Bhushan
    Bhushan avatar
    4 posts
    Member since:
    Sep 2012

    Posted 20 Sep 2012 Link to this post

    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 )....
Back to Top