When I click on this LinkButton I need to save the object on my list, but if I click again, my list will lost the older value and get list count = 1, any suggestion ?
List<Product> products = new List<Product>();
protected void AddProduct_Click(object sender, EventArgs e)
{
int productID = Convert.ToInt32((sender as LinkButton).CommandArgument); /*Pega o id do button que foi clicado relativa a reserva*/
products.Add(ProductBLL.GetProductByID(productID));
ViewState["products"] = products;
}
productsvariable very likely does not persist between sessions. Asmasonsuggested, you need to retrieve your list from the ViewState, not start a new list.