List item doesn't removed

groomy

New Member
I have 2 buttons and a listbox. When I click the 1st button it is supposed to remove the selected item from listbox but it doesn't - the listbox stays the same. What is wrong with the code?\[code\]static List<string> Blist = new List<string>();public int x;protected void Page_Load(object sender, EventArgs e){ Blist = (List<string>)Session["items"]; if (Blist != null) { ListBox1.Items.Clear(); for (int i = 0; i < Blist.Count; i++) ListBox1.Items.Add(Blist); }}protected void Button1_Click(object sender, EventArgs e){ x= ListBox1.SelectedIndex; if (x >= 0) { ListBox1.Items.RemoveAt(x); string m = Blist[x]; Blist.Remove(m); Session["items"] = null; Session["items"] = Blist; }}protected void Button2_Click(object sender, EventArgs e){ Session["items"] = null;}\[/code\]
 
Back
Top