473,324 Members | 2,239 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Can I use "Session" inside a user control ?


I'm creating a paging control in which I want to use a session saved
dataview :

public class PagingControl : System.Web.UI.UserControl
....
....

public void whatever
DataView dw;
if (Session["Results"] != null)
{
dw = (DataView)Session["Results"];
}
else
{
return;
}
At the point of the "if" statement I get a null object reference error.
So, may be I'm trying to do something not allowed ...
Any idea ?

Nov 19 '05 #1
1 1387
Perhaps you're doing this too early in the control's lifetime, like in the
constructor?

-Brock
DevelopMentor
http://staff.develop.com/ballen
I'm creating a paging control in which I want to use a session saved
dataview :

public class PagingControl : System.Web.UI.UserControl
...
...
public void whatever
DataView dw;
if (Session["Results"] != null)
{
dw = (DataView)Session["Results"];
}
else
{
return;
}
At the point of the "if" statement I get a null object reference
error.
So, may be I'm trying to do something not allowed ...
Any idea ?


Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: bajopalabra | last post by:
hi session("myVar") = rs.getRows( ) don't work when number of records is greater than 10 does anybody know WHY ??? is it a Session object limitation ??? thanks
14
by: dale zhang | last post by:
Hi groups, Can anyone give me the equivalent C# sharp code for this VB.ET code, :: VB.NET :: Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _ Handles...
4
by: VB Programmer | last post by:
If I have a variable I want to share in my application what is the difference between just declaring a variable (Dim strMyVar as String) and using a session variable (Session("strMyVar"))? When...
3
by: Jeff Smythe | last post by:
I simply want to execute some code once when a new session of my ASP.NET application is started (I'm not using session state for anything else - just writing some data to a database). I thought...
5
by: jensen bredal | last post by:
I need to keep track on user "session data" while still turning session off as i do not want users login to expire? Thanks JB
6
by: Vincent Finn | last post by:
Hi, I am trying to store an object in the Session() I have a VB.Net control which is loaded in an asp page and then calls a function in my webservice (also written in VB.Net) The web...
4
by: R.A.M. | last post by:
Hello, I am writing ASP.NET application in which I need to use User Profiles and Session mechanisms. Here I include part of my source code (Admin.cs): using System; using System.Data; using...
0
by: Tomasz J | last post by:
Hello developers, My custom control allows for specifying paths to images it uses. In those paths I want to be able to use the "~" app root operator, so my app works correctly with virtual...
3
by: =?Utf-8?B?Sm9obg==?= | last post by:
Hi, I use Session to save and pass values between pages, (please see the following). It works fine on my computer, but on the server, I launch the main page, wait for 20 minutes, and click a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.