Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

urgent: getting data out of a dataset in different subs

Status
Not open for further replies.

gd082

Programmer
Mar 12, 2002
42
BE
I filled a dataset in my page_load sub from an sql-server db. Now i want to extract that same information from my dataset into a variable but in a different sub (for example.. in a clickevent of a button).
Where and how must i declare my dataset to be able to access the data in it everywhere on my webform?

please help
 
You have to assign it to a session variable. What you should do in your page load is this:

Private Sub PageLoad()

If Not Page.IsPostBack 'only fires on first page load
'Insert code here to fill the dataset. Once you have it...
Session("DataSet") = objDataSetYouCreatedAndFilled
End If

End Sub

Now, you just have to access the Session("DataSet") variable and you can get at the data from anywhere in your code.

Any other questions, just ask
:)

Jack
 
thnxs for your help !!

But Can I Use the following statement when i put my dataset in an session variable:

session("dataset").tables("....").rows(0).item("...")

just like i did to extract data from the original dataset?
 
Yeah, you can still use it. Session variables don't utilize Intellisense though, which means you won't have those drop downs appearing to prompt you for what comes next.

It looks like you've got the syntax down anyway though, so you shouldn't have any probs.

Jack
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top