troubleshooting Question

load dataset once use dataview throughout page c#

Avatar of cay187
cay187 asked on
6 Comments1 Solution523 ViewsLast Modified:
i've been using asp for years now and dont have much experience with OOP.  i have a simple question that i cant find the answer to.
How can i load a dataset(2 datatables) on the Page_load() once and the use those tables on different events.

i have a ddl and a gridview.  on the page_load i want to load and populate the dataset - know how to do this
i have a button next to the ddl  user selects ddl value and hits button - know how to do this
onclick event of the button is onclick="button_click"
is there a way that i dont have t requery the DB and just use the datatable that i loaded

 //connect and fill dataset
//bind the ddl
ddl_yards.DataSource = ds.Tables["Yards"];

ds.Tables["Equip"] // datatable just made and not used yet - make this public so that the other functions can see it.  how???????


void button_click(Object Sender, EventArgs e)
  // i dont want to reconnect to the db to access the equip table every time the user click this button.
  // how can i access the "equip" datatable from inside of here that was made on the Page_load()?  so that i can bind it to a gridview - dont know how to do????????
 // do i make the dataset public? private?
 GridView1.DataSource = ds.Tables["Equip"];


Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 6 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros