I'm doing a simple program to add a student(with ID,Name) to a List, then to search Student by ID through session.
Add Student Module is like below,
protected void addStudent(object sender, EventArgs e)
        {
            List<Student> thisstdlist = new List<Student>();
            thisstdlist = (List<Student>)Session["stdlist"];
            thisstdlist.Add(new Student(txtsid.Text,txtsname.Text));
            Session["stdlist"] = thisstdlist;
            Response.Redirect("Home.aspx");
        }
Search Student Module is Like Below,
  protected void searchStudent(object sender, EventArgs e)
        {
            foreach (Student element in (List<Student>)Session["stdlist"])
            {
               if(element.getID().Equals(txtstdid.Text)){
                   txtstdname.Text = element.getName();
               }
           }
        }
Student Class is like below,
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;
        }
    }
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.
 
     
     
    