如何在ASP.net C#中的页面之间传递对象 [英] How to pass objects between pages in ASP.net C#

查看:129
本文介绍了如何在ASP.net C#中的页面之间传递对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我已经在数据访问层类中创建了一个函数...现在,我要从asp.net Web应用程序的用户界面层访问位于数据访问层中的函数. br/> 这是我的代码:
在DataAccessLayer中

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:


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;
        }


现在我想将_SqlDataAccess从包含此代码的当前页面传递到另一个aspx页面. 有人可以打电话给我如何实现这一目标吗?
谢谢.


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.

推荐答案

您不应在页面之间传递这样的数据对象类.如果需要访问单独页面中的数据,则应根据需要使用ID或其他类型的参数来访问每个页面上的数据.您可以使用查询字符串或会话变量来共享信息.
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.


问题不太清楚.但是您可以使用Session之类的东西...
http://msdn.microsoft.com/en-us/library/ms178581.aspx [ ^ ]
The question is not too clear. But you can use stuff like Session...
http://msdn.microsoft.com/en-us/library/ms178581.aspx[^]


这篇关于如何在ASP.net C#中的页面之间传递对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆