title: Storing Data in Session State for a Shopping Cart
body: <p>trying to take what I have stored adding something to a cart into a session
  then transferring it to another page to get a GridView to show up of all the items that I have added onto the Cart session. Storing it as an Object Session.
  -AddToCart takes that rows details and stores in A Session then takes that session object and displays it on a Grid view on another page.</p>
  
  <p>takes this code from it:</p>
  
  <pre><code> protected void GridViewDisplay_RowCommand(object sender,
   GridViewCommandEventArgs e)
   {
   if (e.CommandName == "AddToCart")
   {
   object[] values;
          DataTable orderTable;
          // Retrieve the row index stored in the 
          // CommandArgument property.
          int index = Convert.ToInt32(e.CommandArgument);
  
          // Retrieve the row that contains the button 
          // from the Rows collection.
          GridViewRow row = GridViewDisplay.Rows[index];
          values = new Object[GridViewDisplay.Rows[0].Cells.Count];
          for (int i = 0; i &lt; GridViewDisplay.Rows[0].Cells.Count; i++)
          {
              values[i] = GridViewDisplay.Rows[0].Cells[i].Text;
          }
  
         orderTable = (DataTable)Session["OrderLine"];
         orderTable.Rows.Add(values);
         Session["OrderLine"] = orderTable;
  
  
      }
  
  }
  </code></pre>
  
  <p>Then Now I am trying to take that and store it in a Session so I can display it on a grid view on another page.</p>