title: C# List Elements in the Session Not Responding
body: <p>I'm doing a simple program to add a student(with ID,Name) to a List, then to search Student by ID through session.</p>
  
  <p><strong>Add Student</strong> Module is like below,</p>
  
  <pre><code>protected void addStudent(object sender, EventArgs e)
          {
              List&lt;Student&gt; thisstdlist = new List&lt;Student&gt;();
              thisstdlist = (List&lt;Student&gt;)Session["stdlist"];
              thisstdlist.Add(new Student(txtsid.Text,txtsname.Text));
              Session["stdlist"] = thisstdlist;
              Response.Redirect("Home.aspx");
  
  
          }
  </code></pre>
  
  <p><strong>Search Student</strong> Module is Like Below,</p>
  
  <pre><code>  protected void searchStudent(object sender, EventArgs e)
          {
  
  
              foreach (Student element in (List&lt;Student&gt;)Session["stdlist"])
              {
                 if(element.getID().Equals(txtstdid.Text)){
                     txtstdname.Text = element.getName();
                 }
             }
          }
  </code></pre>
  
  <p><strong>Student Class</strong> is like below,</p>
  
  <pre><code>public class Student
      {
          private String Name;
          private String ID;
  
          public Student(String sid, String sn) {
  
              this.Name = sn;
              this.ID = sid;
  
          }
  
          public String getName() {
  
              return this.Name;
          }
          public String getID()
          {
  
              return this.ID;
          }
  
  
      }
  </code></pre>
  
  <p>But when I added students, for ex: 100,John and Search by 100 it gives me no result. Please can anyone show me the mistake or the correct way of doing this.</p>