日期:2014-05-19  浏览次数:20405 次

asp.net 中 listbox中同时删除多项

帮看看:  
  foreach   (ListItem   aa   in   ListBox1.Items)
                {
                        if   (aa.Selected   ==   true)
                        {
                                this.ListBox1.Items.Remove(aa.Text);
                        }
                }
  报错   :集合已修改;可能无法执行枚举操作。

------解决方案--------------------
别用foreach ,就用for循环,从后向前删
------解决方案--------------------
因为按顺序删除之后ListBox1.Items中的内容已经变化,只能按索引倒着删。