I'm trying to make a program in ASP.net where a user selects products from page 1 (default.aspx), clicks a button to put into shopping cart, and it appears in the second page of product list.
List<string> skuList = new List<string>();
if (validation)
{
foreach (GridViewRow row in GridView1.Rows)
{
if (row.RowType == DataControlRowType.DataRow)
{
CheckBox chkRow = (row.Cells[0].FindControl("chkRow") as CheckBox);
if (chkRow.Checked)
{
skuList.Add(row.Cells[2].Text);
}
}
}
}
else { Response.Write("<script>alert('At least one product need to be selected!');</script>"); }
Session["sku"] = skuList;
The problem I am having is I can not update Session["sku"].
Goal I want to reach:
on Page 1, user chooses product Number 1,2,3, then the session variable get updated to 1,2,3 on Page 2, user continue to choose product Number 8, then the session variable get updated to 1,2,3,8
I tried to do something like
Session["sku"] = Session["sku"] + skulistt;
Of course it didn't work.
List<string> skuList = (List<string>)Session["sku"];ThenskuList.Add("New item");