在会话对象中存储值是否正确?
我试过了,但没有正常工作。我的意思是,存储在会话中的值无法正确访问或存储。谁能帮我解决这个问题?谢谢你。
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Session["cart_table"] == null)
{
DataTable dt = new Spcart().GetCart();
Session["cart_table"] = dt;
}
if (Session["ptax"] == null)
{
Session["ptax"] = 0;
}
if (Session["subtotal"] == null)
{
Session["subtotal"] = 0;
}
BindCartListView();
}
}
public void BindCartListView()
{
----------------------- //some code
int tax=100;
int total=300;
int[] totals;
totals = bindtotal(tax, total);
----------------------------------- //some code
}
public int[] bindtotal(int tax, int total)
{
int ptax = (int)Session["ptax"];
ptax += tax;
Session["ptax"] = ptax;
int subtotal = (int)Session["subtotal"];
subtotal += total;
Session["ptax"] = subtotal;
int granttotal = ptax + subtotal;
Session["granttotal"] = granttotal;
int[] totals = { subtotal, granttotal };
return totals;
}