Your problem is with Session State. When your application sends a web page to the browser the server destroys your application variables. So your dtglobal and dvglobal objects will no longer be instantiated on a subsequent postback.
One way to overcome this problem is to save these objects in session state and retrieve them in Page_Load.
You can add the following lines of code to the end of your "btCreateObjs_Click" method to save the objects in session state:
Me.Session.Add("dtGlobal", dtglobal) Me.Session.Add("dvGlobal", dtglobal)
And, you can add the following lines of code to the Page_Load method to retrieve the objects from session state:
dtglobal = DirectCast(Me.Session("dtGlobal"), DataTable) dvglobal = DirectCast(Me.Session("dvGlobal"), DataView
You need to remember that when the web page is on the client, you are no longer on the server. The only objects retained on the server are those in session state or cache.
This was first published in July 2004