Hey all,
I am making a website for a project which allows the user to "purchase" items. Currently, I have all the items displayed in a grid view which has selection enabled.
When you click this, it stores the cell values into sessions which I retreive on another page as a label (my basket, if you will). What I would like to know is how to go further than just the 1 item, so I click my "Continue Shopping" button and it goes back to my shopping page where I can select another item which will again redirect to basket page and add it along side first item?
I have it working with 1 item at the moment, but when I go back and click another it overwrites the initial session.
Here is the code from my shopping page:
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
Session["CoffeeID"] = GridView1.SelectedRow.Cells[0].Text;
Session["CoffeeName"] = GridView1.SelectedRow.Cells[1].Text;
Session["CoffeePrice"] = GridView1.SelectedRow.Cells[2].Text;
Session["CoffeeStrength"] = GridView1.SelectedRow.Cells[3].Text;
Session["Origin"] = GridView1.SelectedRow.Cells[4].Text;
Session.Timeout = 20;
Response.Redirect("MoreDetails.aspx");
}
And this from the basket page:
protected void Page_Load(object sender, EventArgs e)
{
lblID.Text = Session["CoffeeID"].ToString();
lblName.Text = Session["CoffeeName"].ToString();
lblPrice.Text = Session["CoffeePrice"].ToString();
lblStr.Text = Session["CoffeeStrength"].ToString();
lblOrigin.Text = Session["Origin"].ToString();
}