日期:2014-05-17  浏览次数:20476 次

ListBox传值的问题,进来看看吧
 /// <summary>
        /// 添加
        /// </summary>
        protected void addBtn_Click(object sender, EventArgs e)
        {
            if (lstSelPro.SelectedItem != null)
            {
                if (lstSeledPro.Items.Count>0)
                {
                    foreach (ListItem item in lstSeledPro.Items)
                    {
                        if (item.Text != lstSelPro.SelectedItem.Text)
                        {
                            lstSeledPro.Items.Add(lstSelPro.SelectedItem);
                            lstSelPro.Items.Remove(lstSelPro.SelectedItem);
                            lstSeledPro.SelectedItem.Selected = false;
                        }
                    }
                }
                else
                {
                    lstSeledPro.Items.Add(lstSelPro.SelectedItem);
                    lstSelPro.Items.Remove(lstSelPro.SelectedItem);
                    lstSeledPro.SelectedItem.Selected = false;
                }
                

            }
        }
报错:
错误: Sys.WebForms.PageRequestManagerServerErrorException: 集合已修改;可能无法执行枚举操作。

就是从list1 通过Button传到 list2 有重复就不添加
list button null