把数据初始化显示放到if(!Page.IsPostBack){}里面

解决方案 »

  1.   

    重新绑定
    ListBox1.DataSource = null; 
    ListBox1.DataSource = MyArrayList;
      

  2.   

    有了进展
    现在的问题是
    当del the last row时出错.
    ............
    If lstTest.SelectedIndex <> -1 Then
                GetIndexOk(Me.txtId.Text)
                myDivisions1.RemoveAt(intCurSelectIndex)
                lstTest.DataSource = Nothing
                lstTest.DataSource = myDivisions1
                lstTest.DisplayMember = "getName"
                lstTest.ValueMember = "getId"
    End If
    .............
    此时lstTest默认没有选中行,选中某行时出错.system.ArgumentOutOfRangeExcetion   index值范围出错.
      

  3.   

    经过尝试,lstTest.DataSource =myDivisions1 这种方法在删除时有如上bug! 不能实现.改用lstTest.items.add方法,经过尝试,有如下缺点,
    1.不能备份key值,所有信息都要显示.
    2.修改时,不能及时更新listbox控件.
    例)
    设置
    Me.lstTest.SelectedItem = NewInformation
    但是实际显示
    Me.lstTest.SelectedItem = OldInformation
    -------------------------------------------
    棘手的问题,没有好办法.
      

  4.   

    这个问题我记得有人问过http://community.csdn.net/Expert/topic/3044/3044084.xml?temp=.1090204