Hi all,
I try to display a report in a ReportViewer. My DataSource is an object (frmCorpInfo) in which I have some public properties. At the beginning of the execution, all the variables contained in the class frmCorpInfo are initialized but during the execution time the user can change their values. I would like to display on the report values modified by the user.
Here is an example of my code:
I try to display BN and TypeDesc on the report and even though their values have been changed during the execution time, I always get their initial values (BN is "" and TypeDesc is "CANADIAN CORPORATION"). When I trace the code, those values get modified but in my report I just can’t get the modified values.
What am I doing wrong here?
Many thanks!
I try to display a report in a ReportViewer. My DataSource is an object (frmCorpInfo) in which I have some public properties. At the beginning of the execution, all the variables contained in the class frmCorpInfo are initialized but during the execution time the user can change their values. I would like to display on the report values modified by the user.
Here is an example of my code:
VB.NET:
Public Class frmCorpInfo
#Region " Variable Declarations "
Private dcConnIOFD As IOFD.SQLClientEX.SQLDataConnection
Private BN As String = ""
Private corpTypeDesc As String = "CANADIAN CORPORATION"
Private legalInfoForm As New frmLegalInformation(Me)
...
#End Region
#Region " Public Properties "
Public ReadOnly Property GetConnIOFD() As IOFD.SQLClientEX.SQLDataConnection
Get
Return dcConnIOFD
End Get
End Property
Public Property BN() As String
Get
Return corpBN
End Get
Set(ByVal Value As String)
corpBN = Value
End Set
End Property
Public Property TypeDesc() As String
Get
Return corpTypeDesc
End Get
Set(ByVal Value As String)
corpTypeDesc = Value
End Set
End Property
...
#End Region
#Region " Constructor "
Public Sub New()
'Note: Without this constructor I would get an error message “A data source instance has not been supplied for the data source...”
InitializeComponent()
End Sub
Public Sub New(ByVal strServer As String, _
ByVal strDatabase As String)
Dim ConnIOFD As New IOFD.SQLClientEX.SQLDataConnection(strServer, strDatabase)
ConnIOFD.Connect()
dcConnIOFD = ConnIOFD
InitializeComponent()
End Sub
#End Region
#Region " Event Handler "
Private Sub btnLegalInfo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLegalInfo.Click
Me.Cursor = Cursors.WaitCursor()
legalInfoForm.ShowDialog()
Me.Cursor = Cursors.Default
End Sub
...
#End Region
End Class
Public Class frmLegalInformation
#Region " Variable Declarations "
Private objCorpInfo As frmCorpInfo
#End Region
#Region " Constructor "
Public Sub New(ByRef pobjCorpInfo As frmCorpInfo)
InitializeComponent()
objCorpInfo = pobjCorpInfo
End Sub
#End Region
#Region " Event Handler "
Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
objCorpInfo.BN = txtBN.Text
objCorpInfo.TypeDesc = cbCorporationType.Text
End Sub
#End Region
End Class
I try to display BN and TypeDesc on the report and even though their values have been changed during the execution time, I always get their initial values (BN is "" and TypeDesc is "CANADIAN CORPORATION"). When I trace the code, those values get modified but in my report I just can’t get the modified values.
What am I doing wrong here?
Many thanks!