Error: Deleted row information cannot be accessed through the row

前端 未结 4 1763
一向
一向 2020-12-06 08:47

To whom this may concern, I have searched a considerable amount of time, to work a way out of this error

\"Deleted row information cannot be accessed

相关标签:
4条回答
  • 2020-12-06 09:43

    The current value for the data column in the inner if statement will not be available for deleted rows. To retrieve a value for deleted rows, specify that you want the original value. This should fix your error:

    if (Convert.ToString(ds.Tables[0].Rows[i][0, DataRowVersion.Original].ToString()) == value)
    
    0 讨论(0)
  • 2020-12-06 09:44

    You can also use the DataSet's AcceptChanges() method to apply the deletes fully.

    ds.Tables[0].Rows[0].Delete();
    ds.AcceptChanges();
    
    0 讨论(0)
  • 2020-12-06 09:47

    In your "crashing if", you can check if the row is deleted before accessing it's values :

    if (ds.Tables[0].Rows[i].RowState != DataRowState.Deleted &&
        Convert.ToString(ds.Tables[0].Rows[i][0].ToString()) == value)
    {
        // blaaaaa
    }
    

    Also, I'm not sure why you ToString() the RowState instead of comparing it to DataRowState.Deleted.

    0 讨论(0)
  • 2020-12-06 09:48

    after deleting the row , rebind your grid with the datatable , no need to manually resetting index , datatable handels it.

    so you onl;y need to rebind grid's datasource.

    0 讨论(0)
提交回复
热议问题