Click here to Skip to main content
15,894,460 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I have created a function in data access layer class... Now i want to access the function which is in data access layer from user interface layer which is an asp.net web application.. which i have done like this...
Here is my code:
IN DataAccessLayer
 public class SqlDataAccess
{
public DataSet GetInfo(....)
{...
...
...
}
}

IN UserInterface:
 private SqlDataAccess _SqlDataAccess = null;
protected void Page_Load(object sender, EventArgs e)
        {
            _SqlDataAccess = GetDataFromDataAccess();
           
        }

        private SqlDataAccess GetDataFromDataAccess()
        {
            SqlDataAccess SqlDataAccess = new SqlDataAccess();
            return SqlDataAccess;
        }

Now i want to pass _SqlDataAccess to another aspx page from the current page which contains this code.
Can anybody tel me how to achieve this...
Thank You.
Posted
Updated 16-Feb-12 15:52pm
v5
Comments
[no name] 16-Feb-12 21:52pm    
Format your code snippets

You should not be passing data object classes like this between pages. If you need to access the data in separate pages you should use an ID or other types of parameters to access the data on each page as necessary. You can use query strings or session variables to share information.
 
Share this answer
 
Comments
srk1999 16-Feb-12 17:45pm    
Actually i am trying to pass data access layer object to user interface layer..
jasonterry1 16-Feb-12 18:12pm    
Nischalke is right, rethink this strategy. if you gave an overall concept of what you were trying to do then we could think up a better strategy.
srk1999 16-Feb-12 20:09pm    
I have created a function in data access layer class... Now i want to access the function which is in data access layer from user interface layer which is an asp.net web application.. which i have done like this...
Here is my code:
IN DataAccessLayer
public class SqlDataAccess
{
public DataSet GetInfo(....)
{...
...
...
}
IN UserInterface:
private SqlDataAccess _SqlDataAccess = null;
protected void Page_Load(object sender, EventArgs e)
{
_SqlDataAccess = GetDataFromDataAccess();

}

private SqlDataAccess GetDataFromDataAccess()
{
SqlDataAccess SqlDataAccess = new SqlDataAccess();
return SqlDataAccess;
}
Now i want to pass _SqlDataAccess to another aspx page from the current page which contains this code.
[no name] 16-Feb-12 21:49pm    
Since you are going to repeat your question, I'll repeat my answer. You don't pass such objects between pages.

If your data access code is centralized, say in a separate class, or library, then all you need to share between the pages are the criteria to access it. For instance an ID.










thatraja 16-Feb-12 22:04pm    
5!
The question is not too clear. But you can use stuff like Session...
http://msdn.microsoft.com/en-us/library/ms178581.aspx[^]
 
Share this answer
 
Comments
srk1999 16-Feb-12 17:32pm    
Thanks.. Will try this..
[no name] 16-Feb-12 21:50pm    
Good in theory but it misses the point that such objects should not be stored in session state.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900