How to delete multiple rows from list view

Epicor 10.2.100 does not seem to allow deleting multiple records from list view. If I select multiple rows in the list and hit delete command, only a single active row with an arrow gets deleted. So I am trying to add a command button to the list view. User can check and uncheck a custom field “MarkForDel_c”. When user click this custom button, the code in button click event loop through each record in the list and delete any record where “MarkForDel_c” is checked. The code below does not work consistently. Sometimes, It deletes some marked records, but not all marked records. Sometimes, it even deletes unmarked records. Please see my code below. I tried three different ways, all have similar problem.

Has someone already done this before

Code 1: use row index to loop from last row to first row
EpiUltraGrid eugJM = (EpiUltraGrid) csm.GetNativeControlReference("");

	int n = eugJM.Rows.Count - 1;
  
	for (int i = n; i >= 0; i--)
	{
		if (Convert.ToBoolean(eugJM.Rows[i].Cells["MarkForDel_c"].Value) == true)
		{
			eugJM.Rows[i].Delete();
		}
	}

Code 2: use foreach loop without controlling row sequence
foreach (UltraGridRow gRow in eugJM.Rows)
{
if (Convert.ToBoolean(gRow.Cells[“MarkForDel_c”].Value) == true)
{
gRow.Delete();
}
}

Code 3: use SelectedRows collection
foreach (UltraGridRow gRow in eugJM.Rows)
{
if (Convert.ToBoolean(gRow.Cells[“MarkForDel_c”].Value) == true)
{
gRow.Selected = true;
}
}

	if (eugJM.Selected.Rows.Count > 0)
	{
      eugJM.DeleteSelectedRows();
	}

I figured it out by using EpiDataView

edvJM.dataView[i].Delete();