Session variable between web forms and Data Access Layer

I am using ASP.NET 2.0 with c#. I am trying to declare a global session object that will be used in both c# Class files (DAl) and my web forms (Presentation Tier). Now my session object is Session["Bookid"].  The value stored in this session object is the value from a selected item in my dropdown control. That works fine. But I want this Session object to be used in a (DAL) but the value is null.  Here is exactly what i am trying to do.

1). Select item from dropdown control (from Web form)
2). Assign the selected item to Session["Bookid"]
3). Access that Session object/value to be used in a DAL class file
4). Assign Session["Bookid"] to mySessionValue
5). Put that session value inside a query command.
    Example "Select * from Library where ID = 'mySessionValue'" 

Let me know if this is clear.


Don't forget to click "Mark as Answer" on the post that helped you.
0
WhoIsPrime
3/18/2008 2:34:15 PM
asp.net.state-management 8807 articles. 0 followers. Follow

3 Replies
2253 Views

Similar Articles

[PageSpeed] 56
Get it on Google Play
Get it on Apple App Store

Is your DAL in the same web application as your website?

You might want to rethink how you are doing this and pass your variable as a parameter into a method on the DAL.  You shouldn't rely on session state to much, and should always be prepared if for some reason you lose session state.

0
ely79
3/18/2008 3:20:23 PM

That is a good idea. But how do i accomplish that??


Don't forget to click "Mark as Answer" on the post that helped you.
0
WhoIsPrime
3/18/2008 3:48:50 PM

An example method in your dal could be:

 public void LibrarySelect(string ID)
{
string sql = "select * from library where id = '" + id + "'";
}

0
ely79
3/18/2008 4:03:16 PM
Reply:

Similar Artilces:

Mamanging Cache in Data Access Layer in n-layer Web Application
Hi!   I'm trying to store user object that I get from DB. I'm trying to store it in my DAL instead on code behined. But it doesn't work really well. Sometimes it works, but most of the time it doesn't. I just don't get it. It works ok when I'm doing it in code behined, but I would rather do it in DAL, since I can set SqlCacheDependency that way. I was trying both methodes, Add and Insert. Neither of them works...:(   Any suggestions? Am I getting something wrong here or what? I just don't understand it, because if it wouldn't work, if it wou...

Data Access Layer & Data Layer
what is the difference between Data Access Layer & Data Layer?? Hi,A data layer is where your DB is (or maybe text files). Like your SQL Server DB is your data layer.Data access layer is the code you write to access the data layer and perform operations.HTH,VivekSocial Networking Platform in ASP.NET || Join now: CodeASP.NET Community Please mark the most helpful reply/replies as "Answer"....

ODP.NET
I installed ODP.NEt 2.0 on top of my Oracle client 10g. I am developing a Data Access component. I am having the below problem.  I created the Data Layer class. The constructor of the data layer class initiates a new Oracle Connection.  then I assign the Oracle Transaction obbject to the open connection. In my web page, I instantiate the DataLayer class and then call BeginTransaction method.  At this point, my connection object is null.  What am I missing?  I am getting Externalcontext connection error and Internalcontext error with the error message "Specified slot...

Accessing Session State in Web Service without Cookies enabled in web config
All, We are trying to access a Session variable in web method of a web service. The session variable is set on Page Load in code behind. Some client event is used to make the call directly from javascript to web service. The web method has attribute EnableSession set to true. All is working fine and we are able to access and record session values between web form and web service. The problem arises when we disable the cookies in web config using the following setting: <sessionState cookieless="true" timeout="120"/> The application throws an exception, Auth...

n
The way I see the design in the most basic forms, that the DAL is referenced in Business Logic Layer, where data returned by the entities is stored in a class.That class is referenced by both the UI and BLL. Right? There is no other way to do it I think, because the moment you let the developer reference the entity in UI, then you lose the separation of data.ORRRRRRRRR maybe there is a way to return an Entity Type to UI from BLL without referencing the DAL?BTW I've searched the web, not much there, as I think relatively few systems have yet to take advantage of this technology this deepl...

C#.NET WEB APPLICATION
hei guys, i need help on my application, i'm using C#.NET as front-ed and SQL as back-end, aside from a datagrid, i want to display my data using textboxes and not a datagrid, i can do it using Visual Basic 6 but since i'm a newbee at C#.NET i don't know how to do it, specially the codes, can anyone help me with it? thank you in advance! If you are doing windows development, i would suggest using 'DataForm wizard' (Use Solution Explorer-->Rightclick project-->Add new Item-->New DataForm). It will guide you through steps. If you are doing web apps. Use quickstart to learn them. h...

ORM.NET v.16
Olero Software has released version 1.6 of ORM.NET - the popular object relational mapping and code generation tool. ORM.NET saves .NET developers significant time and effort by generating a complete ADO.NET based Data Access Layer (DAL) modeled on an existing SQL database schema. Version 1.6 NOW SUPPORTS VB.NET code generation as well as the ability to easily customize project namespaces. Download a free trial and see the difference ORM.NET will make on your next .NET project at www.olero.com/ormweb/index.aspx?mp=aspnet Stop manually coding your ADO.NET data access layer! ...

How to access a control on a web form from anoter web form
hi all I have this scenarios i have two web forms, one called form1 and the other called form2 form1 has a label with id "lbl1" is it possible to access lbl1 from form2, change its text permenantly? thanks.   refer: http://dotnetslackers.com/Community/blogs/haissam/archive/2007/11/26/ways-to-pass-data-between-webforms.aspxSSNPlease remember to click "Mark as Answer" on the post that helps you. MinaSamy: hi all I have this scenarios i have two web forms, one called form1 and the other called form2 form1 has a label with id "lbl1" is it p...

Accessing two web forms in a single web form
  Hi. I am developing a website in VS 2005 with Ajax & SQL Server. I am having 5 forms in my application. 1) Login Form 2) Main form 3) Form "A" 4) Form "B" I need to show the main form after the User login. I need to show all the contents of form A or form B (Ex: Form "A" user or form "B" user) in the Main Page. Can I show a single page having Main Form controls as well as Form "A" and Form "B" controls? I should access all the controls including Form A/B in the Main Page. Thanks ...

State Management in Web Forms
This article discusses the ways in which the state management can be handled in web forms. State management can be done either on client side or server side as explained below. Author-Jalajakshi Venkataramana http://www.dotnetbips.com/displayarticle.aspx?id=247...

Needed Experts Only Reply: Unable to access dynamic user controls data using global variable (except session/application variable)
Hi All, I have 1 or more dynamically assigned user controls. Now I need to pass a user control's value to another user controls during page load. We can do using session variable, but the problem over here is it would slow down my application. So I would like to attain this without using the session or application variable. Please go through my sample codes below; User Control 1: ------------------ Public Class UserControl1 Protected WithEvents txtFirstName As System.Web.UI.WebControls.TextBox Protected WithEvents txtLastName As System.Web.UI.WebControls.Text...

Submitting data from a know web form to unknown web form
hi i m making a software in which i will submitt some data from a web page that will go to a web form of which contrlos are unknown to me only i know the name and how many controls in that form it means i can see the form only. how can i do this please help me soon with code plz its very argent.i m doin this wit the help of foxtrot.xray.WebRobot but its giving me error that this dll file is already exists in The file ('C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\_foxtrot.xray.WebRobot.dll' already exists).i don know what will do so please help me soon please thanks praveen We ca...

Request to Core Team Members : Unable to access dynamic user controls data using global variable (except session/application variable)
Hi All, I have one or more dynamically assigned user controls. Now I need to pass a user control's value to another user controls during page load. We can do using session variable, but the problem over here is it would slow down my application. So I would like to attain this without using the session or application variable. Please go through my sample codes below; User Control 1: ------------------ Public Class UserControl1 Protected WithEvents txtFirstName As System.Web.UI.WebControls.TextBox Protected WithEvents txtLastName As System.Web.UI.WebCont...

4 Layered Web Application for Inserting data into a database using sql server as the back end and a web form as the front end using C#
4 Layered Web Application for Inserting data into a database using sql server as the back end and a web form as the front end using C# . Can someone provide with code as I am new to this architecture and framework. Better send email. Thanks In Advance, A New Bie I suggest taking a look at the Time Tracker Starter Kit (v1.x or x2.0) or the Issue Tracker Starter Kit (v1.x).  Full source code is available.  Click on the Downloads tab above to find them.  These are not exactly what you are looking for, but perhaps they will help you get started.Terri MortonEngagement Manag...

Web resources about - Session variable between web forms and Data Access Layer - asp.net.state-management

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 ...

Staley: 'A lot of different variables...been a hard year'
... 41° Navigation Home Giants A's Sharks Warriors Kings 49ers Raiders Quakes Insiders More Tickets Shop Watch Staley: 'A lot of different variables...been ...

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: 1/22/2016 2:58:18 AM