title: how to store multiple selected listbox items in a session and view on another form?
body: <p>The thing I want to do is that i want to select 1,2 or 3 items from the listbox and save them into a session and then display them all on another form in a listbox.</p>
  
  <p>Here's my code!
  This is my first post on stack overflow, so no hate please &lt;3</p>
  
  <pre><code>    //WebForm1
  
      protected void Page_Load(object sender, EventArgs e)
      {
          if (!IsPostBack)
          {
              lstProducts.Items.Add("Soap");
              lstProducts.Items.Add("Schampoo");
              lstProducts.Items.Add("Conditioner");
          }
      }
  
      protected void cmdBuy_Click(object sender, EventArgs e)
      {
              string[] products = new string[3];
  
              for (int i = 0; i &lt; lstProducts.Items.Count; ++i)
              {
                  if (lstProducts.Items[i].Selected)
                      products[i] = lstProducts.Items[i].Text;
                  else
                      products[i] = "0";
              }
  
              Session["Cart"] = products;
  
      }
  
      protected void cmdCart_Click(object sender, EventArgs e)
      {
          if (Session["Cart"] != null)
          {
              Response.Redirect("WebForm2.aspx");
          }
      }
  }
  
  
      //WebForm2
  
  
      protected void Page_Load(object sender, EventArgs e)
      {
          string[] products = (string[])Session["Cart"];
  
          for (int i = 0; i &lt; 3; ++i)
          {
              if (products[i] != "0")
              {
                  lstCart.Items.Add(products[i]);
              }
          }
      }
  }
  }
  </code></pre>
  
  <p>The thing is that I only get the last selected item to display in the listbox on form2???</p>