索引超出范围。必须为非负值并小于集合大小。参数名: index 
是什么意思???

解决方案 »

  1.   

    在 
    userid = DataGrid1.DataKeys(e.Item.ItemIndex) '获得主键值
    行提示错误!
      

  2.   

    void MyDataGrid_Delete(Object sender, DataGridCommandEventArgs e) 
          {
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    //         //dowith the Bug of Del&Page
               if((CartView.Count%MyDataGrid.PageSize==1)&&(MyDataGrid.CurrentPageIndex!=0))
               MyDataGrid.CurrentPageIndex--;
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~         DataRow dr;
             String ID = e.Item.Cells[2].Text; 
             //
             DEL_From_Grid(ID);
             //
             CartView.RowFilter = "ID='" + ID + "'";
             if (CartView.Count > 0)
                CartView.Delete(0);
             CartView.RowFilter = "";
     
             BindGrid();
         }
      

  3.   

    判断当前page是不是只有一条记录!!!
    如果是,
    DataGrid1.CurrentPageIndex=0;
    ( or DataGrid1.CurrentPageIndex=DataGrid1.CurrentPageIndex-1;;
      

  4.   

    用asp.net--vb这个该怎么编写?
      

  5.   

    到这去把c#转成vb.net的
    http://www.aspalliance.com/aldotnet/examples/translate.aspx
      

  6.   

    我想有两个原因;不知道你加了没有1.你的DataGrid 的DataKeyField设置主键ID没有
    2.你绑定到DataGrid的Table加主键了没有;DataColumn[] dcPk = {user_DS.Tables[tableName].Columns["ID"]};  //对一个Data
    user_DS.Tables[tableName].PrimaryKey = dcPk;
      

  7.   

    把myDataGrid_DeleteCommand1事件里加上:if e.item.itemindex>=0 then....你的代码end if