public string Add() { ArrayList arr; if (Session["mycart"] != null) { arr = (ArrayList)Session["mycart"]; } else { arr = new ArrayList(); Session["mycart"] = arr; } EmailTextBox.text = EmailGridView.rows(0).cells(1).text.ToString CShoppingCartItem item = new CShoppingCartItem(); //item.ProductID = int.Parse(ReciveId); //int.Parse(GridView1.Rows[0].Cells[2].Text.ToString()); <big> item.ProductName = GridView1.Rows[1].Cells[1].Text;</big> .// item.Quantity = 1; arr.Add(item); return "s"; }
Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
else { arr = new ArrayList(); Session["mycart"] = arr; }
check the index of rows and cells. check if there is any value or not. try 0 instead of 1 in 'rows[1]'. like:- GridView1.Rows[0].Cells[1].Text;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)