Hi
i have created a ASP page and declared a dataset at class level. I fill this datase at a push button1 code. After this i try to use the same dataset object at another push button2 event but it says that the dataset is empty (Nothing)
Here is my code
Public Class WebForm1
Inherits System.Web.UI.Page
Dim dsClassLevel As DataSet
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ds As DataSet
'With my code I fill the ds with my data here
dsClassLevel = ds 'Assign the class level dsClassLevel
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
dim str1 as string
'Here it gives the following exception
'System.NullReferenceException: Object reference not set to an instance of an object.
str1= dsClassLevel.Tables(0).Rows.Count()
End Sub
end class
i have created a ASP page and declared a dataset at class level. I fill this datase at a push button1 code. After this i try to use the same dataset object at another push button2 event but it says that the dataset is empty (Nothing)
Here is my code
Public Class WebForm1
Inherits System.Web.UI.Page
Dim dsClassLevel As DataSet
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ds As DataSet
'With my code I fill the ds with my data here
dsClassLevel = ds 'Assign the class level dsClassLevel
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
dim str1 as string
'Here it gives the following exception
'System.NullReferenceException: Object reference not set to an instance of an object.
str1= dsClassLevel.Tables(0).Rows.Count()
End Sub
end class