Wrox Programmer Forums
|
ASP.NET 1.x and 2.0 Application Design Application 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 5th, 2003, 02:07 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default DataSet Scope

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.

Thanks!!

Jim



 
Old December 5th, 2003, 02:52 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

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.

Peter
------------------------------------------------------
Work smarter, not harder.
 
Old December 5th, 2003, 02:56 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Yes it is there... That's why I am confused by this behavior






Similar Threads
Thread Thread Starter Forum Replies Last Post
Scope of Objects Handman BOOK: Professional C# 2008 ISBN: 978-0-470-19137-8 12 October 20th, 2008 10:06 AM
Scope Issue iceman90289 C# 2005 8 April 5th, 2008 03:41 PM
what is the scope of PHP raaj Beginning PHP 1 February 13th, 2007 12:51 AM
the scope of variable ccj_999 C++ Programming 9 October 26th, 2006 10:35 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.