我已经在会话变量中存储了哈希表,现在我想在不同标签的其他页面上检索其数据 [英] i have stored hash table in a session variable now i want to retrieve its data on other page in different labels
本文介绍了我已经在会话变量中存储了哈希表,现在我想在不同标签的其他页面上检索其数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已将哈希表存储在会话变量中,现在我想在不同标签的其他页面上检索其数据。
i have stored hash table in a session variable now i want to retrieve its data on other page in different labels.
推荐答案
请参阅:http://forums.asp.net/t/1353450.aspx [ ^ ]请记住,不应将大数据存储到会话中。
See this : http://forums.asp.net/t/1353450.aspx[^] Remember, you should not store large data into session.
As hastable存储keyvaluespair值,你必须将keyvalue对存储在hastable中。
请参考以下示例...在此示例中,我将数据存储在一个页面的会话变量中,并将其访问到另一个页面。
希望这会对你有所帮助。
default.aspx.cs
As the hastable stores the keyvaluespair values, you have to store keyvalue pair in hastable.
refer the following example for the same.. in this example i am storing data in session variable from one page and access it in to another page.
hope this will help you.
default.aspx.cs
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
try
{
Dictionary<int, string> dict = new Dictionary<int, string>();
dict.Add(1, "value1");
dict.Add(2, "value2");
Hashtable ht = new Hashtable(dict);
Session["data"] = ht;
Response.Redirect("default2.aspx", false);
}
catch (Exception)
{
throw;
}
}
}
default2.aspx。 cs
default2.aspx.cs
public partial class default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Session["data"] != null)
{
Hashtable ht = Session["data"] as Hashtable;
}
}
}
这篇关于我已经在会话变量中存储了哈希表,现在我想在不同标签的其他页面上检索其数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文