title: Trying to pass a string between C# classes
body: <p>I'm trying to pass a string between C# classes by using a session. I have a class called <code>Profile</code> and it has a search box. I have another class called <code>SearchResults</code> that is supposed to search my database for whatever was entered in the search box. </p>
  
  <p>Upon clicking on the search button, this method in the <code>Profile</code> class is called:</p>
  
  <pre><code> protected void Search(object sender, EventArgs e)
   {
       Response.Redirect("~/SearchResults.aspx");
       String searchedItem = txt_search.Text;
       Session["search"] = searchedItem;
   }
  </code></pre>
  
  <p>and here is the <code>Page_Load</code> method in the <code>SearchResults</code> page:</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
  {
  
      string searchedItem = (string)(Session["search"]);
  
      string connStr = ConfigurationManager.ConnectionStrings["MyDbConn"].ToString();
      SqlConnection conn = new SqlConnection(connStr);
      SqlCommand SearchGames = new SqlCommand("SearchGames", conn);
      SearchGames.CommandType = CommandType.StoredProcedure;
      SearchGames.Parameters.Add(new SqlParameter("@game_name", searchedItem));
  
      conn.Open();
  
      SqlDataReader rdr = SearchGames.ExecuteReader(CommandBehavior.CloseConnection);
  
  }
  </code></pre>
  
  <p>I'm getting an error saying that my </p>
  
  <blockquote>
    <p>SearchGames procedure needs an @game_name parameter which wasn't
    supplied</p>
  </blockquote>
  
  <p>, however it's clear that I've passed that parameter, which leads me think that there's something wrong with <code>SearchItem</code> (or how I'm passing the string between the two classes.</p>