ASP.NET 1.x and 2.0 Application DesignApplication design with ASP.NET 1.0, 1.1, and 2.0.
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 1.x and 2.0 Application Design section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
The problem I am having is that if I try to access my dataset outside of the event where it was filled, it is empty. I added the dataset to the page using the IDE, so I thought once it was filled it was public, this does not seem to be the case. Why, what is it's scope?
In order to try to get around calling the SQL again, I placed the dataset into a session variable. I tried to set the datasource of a data grid using it. dg1.datasource = Session("var"). It did not like this. So, I tried to convert the session to a dataset using CType, it does not like that either.
How can I make my dataset global so I do not have to keep hitting the database? I just want to fille the ds once and access it from anywhere in the page.
If you add the dataset with the IDE, it *should* be accessible anywhere in the page class. It should be declared as a protected member of the class. It won't be Public, but Protected. Either way, you should be able to see it.
Check the code, in the "Web Form Designer Generated Code" code region. You should see the dataset object declared in there.
Work smarter, not harder.