Here in the code behind I am creating a link and adding a click event handler:
LinkButton newX = new LinkButton();
newX.Text = "x";
newX.Attributes.Add("problem", problems[p]);
newX.Click += new System.EventHandler(this.RemoveItemFromBucket);
The link is appearing fine on the page. However, when I run in Debug mode and set a break point on the first line of the handler:
public void RemoveItemFromBucket(object sender, EventArgs e)
        {
            string problem = (sender as LinkButton).Attributes["problem"];
...
        }
The event does not fire.
Posting my load and PreInit code as requested:
protected void Page_Init(object sender, EventArgs e)
        {
            if (Session["elders"] == null)
            {
                Session["elders"] = (from s in masterDB.SnoMedElders select s).ToList();
            }
            if (Session["snoMed"] == null) {
                Session["snoMed"] = (from s in masterDB.mrconso_SnoMed2014_LimitedToDiseaseBranches select s).ToList();
            }
            if (Session["relations"] == null)                
            {
                Session["relations"] = (from s in masterDB.mrrel_SnoMed2014_LimitedToDiseaseBranches select s).ToList();
            }           
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["UserRole"] == null)
                Response.Redirect("Login.aspx");
            UnmappedNum.Text =  ((from t in (Session["elders"] as List<SnoMedElder>)
                                select t.SnoMedScui).Distinct().ToList().Count() -
                                (from t in masterDB.tbl_patients_problems_to_snomed_buckets_2014s
                                select t.SnoMedScui).Distinct().ToList().Count() + 600).ToString();
        }
Edit: Figured out the problem. The problem is that my whole page is in an ajax update panel. When I add an element dynamically, it does not get added into the update panel so the whole page is reloading. How do I add an element to an update panel?