I need to add the itemid from the list of rows when i click 'add to cart' button in the gridview, i was able to pass this itemid to a arraylist. but the problem is that everytime i click the button the previous itemid is overwritten with the new item instead i want the arraylist to expand.
public partial class Drama_k : System.Web.UI.Page { string Cn=@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ewap_k.mdf;Integrated Security=True;User Instance=True"; ArrayList arrValues = new ArrayList(4);
protected void GridView2_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName=="AddToCart") { int index = Convert.ToInt32(e.CommandArgument); Session["item"] = GridView2.DataKeys[index].Value.ToString(); arrValues.Add(Session["item"]); GridView1.DataSource = arrValues; GridView1.DataBind(); } } }
thank you,