Hi all,
I found this forum really useful and I hope this question can be answered here as well.
I have an object declared in a class (a custom user control) and assigned value in a sub; I then try use another sub (a property Get) to retrieve the value and return it to the caller - in vain with VB Studio.Net showing the object is not instantiated at all in the sub. I wonder shouldn't declaring the object in the class makes it persistent throughout the class?? I then tried to make it a Shared object but it won't work either. Does it have to do with loading? Will the object loss it value because the page is postback? Could anyone help please!! this is very urgent work!!
Thanks Heaps!!
excerpts of code:
PublicClass directlink
... [code omitted]
I found this forum really useful and I hope this question can be answered here as well.
I have an object declared in a class (a custom user control) and assigned value in a sub; I then try use another sub (a property Get) to retrieve the value and return it to the caller - in vain with VB Studio.Net showing the object is not instantiated at all in the sub. I wonder shouldn't declaring the object in the class makes it persistent throughout the class?? I then tried to make it a Shared object but it won't work either. Does it have to do with loading? Will the object loss it value because the page is postback? Could anyone help please!! this is very urgent work!!
Thanks Heaps!!
excerpts of code:
PublicClass directlink
Inherits System.Web.UI.UserControl
PrivateShared dtContractor As DataTable
PrivateShared dtContractor As DataTable
... [code omitted]
Private
Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Load
'Put user code to initialize the page here
If (Page.IsPostBack = False) Then
sbDataBind()
EndIf
EndSub
PrivateSub sbDataBind()
dtContractor.Columns.Add(New DataColumn("EligibilityNumber", Type.GetType("System.Int32")))
dtContractor.Columns.Add(New DataColumn("ProviderName", Type.GetType("System.String")))
dtContractor.Columns.Add(New DataColumn("Contractor", Type.GetType("System.Boolean")))
dtContractor.Columns.Add(New DataColumn("MaxContractorNumber", Type.GetType("System.Int32")))
...[omitted code for adding data in rows]
PublicReadOnlyProperty SelectedTexts() As DataTable
End ClassIf (Page.IsPostBack = False) Then
sbDataBind()
EndIf
EndSub
PrivateSub sbDataBind()
dtContractor.Columns.Add(New DataColumn("EligibilityNumber", Type.GetType("System.Int32")))
dtContractor.Columns.Add(New DataColumn("ProviderName", Type.GetType("System.String")))
dtContractor.Columns.Add(New DataColumn("Contractor", Type.GetType("System.Boolean")))
dtContractor.Columns.Add(New DataColumn("MaxContractorNumber", Type.GetType("System.Int32")))
...[omitted code for adding data in rows]
PublicReadOnlyProperty SelectedTexts() As DataTable
Get
...
dtRow("Contractor") = Me.dtContractor.Rows(i)("Contractor")
...
EndGet
EndProperty...
dtRow("Contractor") = Me.dtContractor.Rows(i)("Contractor")
...
EndGet