void DeleteBtn_Click(object sender, EventArgs e) { HtmlButton b = (HtmlButton)sender; if (b != null) { String id = b.ID; int index = id.IndexOf("-"); String value = id.Substring(index + 1); int num = Convert.ToInt16(value); Control c = TableContainer.FindControl(id); TableContainer.Controls.Remove(c); Control cb = TableContainer.FindControl("Break-" + num); TableContainer.Controls.Remove(cb); dict.Remove(num); } else { Console.WriteLine("The source of the trigger was not an HTMLButton, Ignoring.."); } }