二维会话变量 [英] Two Dimension Session variable

查看:84
本文介绍了二维会话变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好



我的代码



protected void RadioButton1_CheckedChanged(object sender,EventArgs e)

{

RadioButton rb1 = null;

RadioButton rb2 = null;

RadioButton rb3 = null;

RadioButton rb4 = null;

RadioButton rb5 = null;

RadioButton rb6 = null;





foreach(dlDisplayAll.Items中的DataListItem项目)

{

rb1 =(RadioButton)item.FindControl(RadioButton1);

rb2 =(RadioButton)item.FindControl(RadioButton2);

rb3 =(RadioButton)item.FindControl(RadioButton3);

rb4 =(RadioButton)item.FindControl(RadioButton4);

rb5 =(RadioButton)item.FindControl(RadioButton5);

rb6 =(RadioButton) item.FindControl(RadioButton6);



if(rb1.Checked == true)

{

Session [Size] =Small;

}

else if(rb2.Checked == true)

{

Session [Size] =Medium;

}

else if(rb3.Checked == true)

{

Session [Size] =Large;

}

else if(rb4.Checked == true)

{

Session [Size] = XL;

}

else if(rb5.Checked == true)

{

Session [大小] =XXL;

}

否则if(rb6.Checked == true)

{

会话[大小] =XS;

}

}

}



和viewcart.cs文件



str11 + =

< input type =''Text''id =''size+ cnt1 +''value =+ Session [Size]。ToString()+readonly>
;



现在当我在购物车中添加一个项目时,它会显示所有尺寸为ID等的信息。现在我继续购物并在购物车中添加新商品,而不是两个商品的尺寸相同,因为我使用了会话[尺寸]一个会话现在我怎么能用它的产品id

Hello

My Code

protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
{
RadioButton rb1 = null;
RadioButton rb2 = null;
RadioButton rb3 = null;
RadioButton rb4 = null;
RadioButton rb5 = null;
RadioButton rb6 = null;


foreach (DataListItem item in dlDisplayAll.Items)
{
rb1 = (RadioButton)item.FindControl("RadioButton1");
rb2 = (RadioButton)item.FindControl("RadioButton2");
rb3 = (RadioButton)item.FindControl("RadioButton3");
rb4 = (RadioButton)item.FindControl("RadioButton4");
rb5 = (RadioButton)item.FindControl("RadioButton5");
rb6 = (RadioButton)item.FindControl("RadioButton6");

if (rb1.Checked == true)
{
Session["Size"] = "Small";
}
else if (rb2.Checked == true)
{
Session["Size"] = "Medium";
}
else if (rb3.Checked == true)
{
Session["Size"] = "Large";
}
else if (rb4.Checked == true)
{
Session["Size"] = "XL";
}
else if (rb5.Checked == true)
{
Session["Size"] = "XXL";
}
else if (rb6.Checked == true)
{
Session["Size"] = "XS";
}
}
}

and in viewcart.cs file

str11 += "

<input type=''Text'' id=''size" + cnt1 + "'' value=" + Session["Size"].ToString() +" readonly>
";

now when i add one item in cart it display all information with size id etc. now i continue shopping and add new item in cart than size of both item gone same because i used Session[Size] one session now how i can do size with it''s product id

推荐答案

你只能在一个条件下传递几乎所有的会话变量:对象应该是< I>可序列化的。这不合乎逻辑吗?



这里有很好的解释: http://msdn.microsoft.com/en-us/library/ms178581%28v=vs.100%29.aspx [ ^ ]。



-SA
You can pass nearly anything as a session variable, under only one condition: the object should be serializeable. Isn''t this logical?

This is well explained here: http://msdn.microsoft.com/en-us/library/ms178581%28v=vs.100%29.aspx[^].

—SA


这篇关于二维会话变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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