Getting value out of session variable


How to get the value of a session. It is storing the dataset value. I dont know how to transfer that to a variable.

   private SearchDotnet.Searchs.UserSearch sSite;

 if ((sSite == null))
             sSite = Session["Site"];


The thing is sSite is  delcared as above. I need to unload the session variable to sSite. Have not found a clue yet.


Thanks in advance




3/12/2009 8:51:27 AM 93655 articles. 6 followers. Follow

6 Replies

Similar Articles

[PageSpeed] 47

I think when you read a value from Session, you need to cast it to the correct object type.  In this case if it's a dataset, then cast it to DataSet.

C# <---> VB.Net Translator
3/12/2009 12:20:50 PM
if Session["Site"] contains a dataset then this way 
DataSet ds = (DataSet)(Session["Site"])
3/12/2009 12:25:48 PM

 what is that sSite ?


if its is a string then


sSite =(string) Session["Site"];


may be for your case

sSite =(SearchDotnet.Searchs.UserSearch) Session["Site"];  might work



3/12/2009 12:26:16 PM
You can store the dataset in the session like this...
DataSet ds = new DataSet();
if you want to retrieve the data set from session....
Dataset ds1 = (DataSet)Session["myDataSet"];

3/12/2009 12:31:03 PM

Try like this

Dataset objDS; 

If (Session["Site"] != null)


objDS = Session["Site"] as Dataset;


Dont forget to click "Mark as Answer" on the post that helped you
3/12/2009 12:43:12 PM

Wow, that is a lot of help.


I will try this out and get back here.

Thanks a lot.

3/12/2009 1:17:11 PM

Similar Artilces:

How to get session variable value into a static variable
Hi, On page preinit i am adding few session variables. Now i want to retrive these session variable values into my static variables. protected void Page_PreInit(object sender, EventArgs e) {Session.Add("T", "Default"); Session.Add("T1", "Red"); Session.Add("T2", "Blue");   }   i have few static variables which shud contain these vaules.  public string TT; public string TT1; public string TextForeColor =sess = "#FFFFFF";   i want to get T value into TT ... T1 into TT1..and so on &n...

getting values from a web form to windows form
Hot Requirement ..... Is there any possible of getting values from a web form to windows form ????? Yes One way i to use the WebRequest and WebResponse classes of the System.Net namespace. For example:  WebRequest request = WebRequest.Create("URL of the web page); WebResponse response = request.GetResponse(); StreamReader reader = new StreamReader(response.GetResponseStream()); string content = reader.ReadLine(); ....    Reza Nassabehwww.professionalcsharp.comDon't forget to click "Mark as Answer" on the post that helped you. That way fut...

how i can get the one form variable values in other forms?????
iam going to pass values of one form to another formlike asfollows.. f1=CType(Context.Handler ,f1);here f1 is form object this will be used in some other form.iam try ing to use to global variables of first form in to second form.while compilation it show s an error like as follws:"The name 'CType' does not exist in the class or namespace 'PassingValuesForms.Form2'can you giv aslo pls..thanks in advance..ramsCheersRam MCP CType is for the VB.NET language exclusively. By adding a semicolon to your code, I'm guessing you are using C#.CType provides VB users with typecasting. In C#, the lang...

Passing Values from a Web Form to Another Web Form
Hello All! I am trying to pass values from one web form to another web form. I know that there are 3 ways of doing this: queryString, Server.Transfer and Session. I am using the Server.Transfer method. But I am not able to create, in my 2nd web form, an instance of my 1st web form. My 1st Web form is named CallTrack.aspx and my 2nd is named Export.aspx. What I mean is something like this: Public value as CallTrack. I can't create it in my 2nd web form because when the intellisense is displayed, there's no CallTrack in the options. Thanks!   How about using cross-...

getting value of session variable
I'm trying to display the value of a session variable in a label. I know the session variable exists because in my page load event I redirect the user to a different page if it's value is null. I want to display it's value in a label to test some things, but I keep getting an error whenever I try.  Here is my code:   Label:<asp:Label ID="lblSessionTest" runat="server" Text="Label"></asp:Label>  How I'm trying to display it (in my page load event):  lblSessionTest.Text = Session("loggedIn"); &nbs...

Session Variables (Get values)
Hi, I am storing some variables in Session, Double values, Integers and Strings.Sometimes these values can be null or empty (""). While retrieving these values from session I will declare a variable of its type. Let say for example I want to get a Double value from Session. Dim dblAmount as DoubledblAmount = Session("sessAmount") Here I am getting trouble when value is empty, its giving an errorConversion from string "" to type 'Double' is not valid. How to handle this kind of situations? Let me know your suggestion. Thanks   Hi. Before assigning the value, check if the session...

How to get the HREF value of the Anchor tag in a web page using the web browser control in
Hi Friends,               i have a webserver control in my application.i load the web browser control on a button click using the below code Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click                AxWebBrowser1.Navigate("", False) End sub once the page is loaded in the browser i want the <a> HREF value in that page.For example if that page has ...

How to get session variable values in webpart?
Anyone know that how to get session variable values in webpart? I developed a ASP.NET page to accept a input order code e.g. "E923829" and set it as session variable for the following working page. One of the working page is containing a webpart to show this order summary e.g. number of items and total price. I'm using VB.NET to develop this webpart. I'd tried to use Dim OrderNumber as string = Page.session("ORDER_NUMER"). But this will cause error while loading the webpart. Your advice will very appreciated....

Get listbox value from the other web form
 Dear all, I want to get the lisbox selecteditem value to a textbox in one web form from the other web page. Should I use session to get this value?Can any one help in this regard? Thanks a lot in advance.  People Develop People Yes you can use Session to get the informations between cross pages.. see below for your referenceTO STORE THE INFO in Session Session["key"] = ListBox1.SelectedItem.Value; Response.Redirect("Page2.aspx");TO GET THE VALUES FROM Sessionprotected void Page_Load(object sender, EventArgs e){    if (Sessio...

Getting a session variable value in Servlet
Hi, I am using psSession to set and get session variables in PowerDynamo scripts. I also had to use servlets for serving some of the pages. I want to access the session variables I have set in PowerDynamo scripts from my servlet. I tried session.getValue from my servlet. But it returns a null in servlet. Any ideas as to how I can get the values of session variables in my servlet? TIA, Mani. Mani, I would think that because they are two different session types you could not do this. A workaround would be to create a cookie that you can use from either spot Scott ...

session variables in javascript on a web form
Hi All, I have master page on which I have written a javascript which open ups a new window when user clicks on menu item placed on the left side of master page. The javascript follows  function OpenWind()       {         <% if( HttpContext.Current.Session["Id"]==null) { %>                alert('Session Expired! Redirecting to login page!');           &nb...

Session variable value gets lost
I am using 3.0 with C#. My web application requires some values that is used across my User Controls. These values are pertaining to the login user name and User type. When each user is logged in I store that username and user type in a session variable and whenever i need to used it like in a query I just called the string variable that is assigned to the Session variable. My problem is sometimes my session object/ string variable loses its value and I am wondering is there another way of storing my User's credential so that the value will not be lost until the User closes his/h...

Implementing .Net Form into an web form, can this be done
I am new here, but have been searching for a while, and may not have the correct lingo to find what I am looking for.  I am tasked with implementing a .exe application that was writen vb6 then converted to .net into a new website my team is developing. The idea is to put each of the 3 different forms in this .exe application of 3 different .aspx pages. I have attempted multiple things to get this into the page and even started to just rewrite it as an web form, but even then I can't reuse any of the code since the System.Web.UI.Page doesn't inherit the sa...

Get value of hidden gridview into session variable
 Hello and thanks for any ideas on this in advance.I have a hidden casegridview from a sqldatasource with 2 values (case_id, client_id) The case gridview datasource takes a client id parameter from a second gridview, clientI'm trying to get the case_id into a session variable and can't figure out how to do it.I tried using onselectindexchange for gridview2 but that didn't return anything because gridview2 doesn't have select enabled.I have this code for my client gridview that gets a client id into a session variable: protected Sub GridView1_SelectedIndexChange...

Web resources about - Getting value out of session variable -

Variable - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

Westpac interest rate rise is one of many variable loan rate rises
WESTPAC is not alone in hitting its owner-occupier customers with a surprise interest rate rise, as dozens of other variable rate home loans ...

Airbnb upgrades variable pricing tool for hosts
Online home rental group Airbnb is rolling out an upgraded variable pricing tool that automatically raises or cuts room rates based on supply ...

Commonwealth Bank raises variable home loan rates
Home owners' mortgage costs are set to rise by hundreds of dollars a year, after the Commonwealth Bank became the latest bank to hike interest ...

CBA lifts variable home loan rates to offset costs associated with stricter capital requirements
The Commonwealth Bank to lift its home loan interest rates independently of the Reserve Bank to partially offset costs associated with stricter ...

Washington Square Signs Spielbergs, Choi Joins Variable and More
... films and an episode of the HBO comedy series "Girls," on which he plays the role of Ray Ploshansky. New York-based creative collective Variable ...

YouTube v10.32 Tweaks Some Interface Elements And Includes Hints About Virtual Reality Content And Variable ...
Forget Update Wednesday! Monday is the new big day. Not only were we treated to the latest M preview release and the official Marshmallow name, ...

"You have to ignore many variables to think women are paid less than men. California is happy to try." ...
Writes Sarah Ketterer in The Wall Street Journal in "The ‘Wage Gap’ Myth That Won’t Die" (which you can get to without subscribing if you Google ...

Cisco Debuts Open Pay Variable Pricing, Updates CCRE
Cisco Debuts Open Pay Variable Pricing, Updates CCRE Channel Partners Kris Snow, president of Cisco Capital, says the company's new Open Pay ...

Expert Reveals the Latest Variable Capacity Technology
Learn about gForce Ultra CRAC equipment, the latest variable capacity technology to lower energy usage and increase reliability.

Resources last updated: 12/1/2015 3:44:21 PM