i have infragistics grid where user can select multiple rows and delete items by rt clicking the "delete rows" option . The datasource of the grid is an entitycollection. when multiple rows are selected and "delete rows" is clicked...i am collecting each of the entity from selected row to a "temp" entitycollection, deleting it from the DB and finally removing it from the entitycollection that is the datasource.
But on the last entity the system freezes on EntityCollection.Remove(entity). statement...like its going on a infinite loop. here is the actual code.
EntityCollection<CustomerMarkUpEntity> CustomerMarkUpCollection = new EntityCollection<CustomerMarkUpEntity>();
EntityCollection<CustomerMarkUpEntity> CustomerMarkUpCollectionToDelete = new EntityCollection<CustomerMarkUpEntity>()
public void ShowCustomerMarkUp()
{
// get the markup collection and set the data source of the grid.
CustomerMarkUpCollection =....
....
CustomerMarkUpGrid.DataSource = CustomerMarkUpCollection;
}
// delete record by rt clicking "delete row"
private void deleteRecordsToolStripMenuItem_Click(object sender, EventArgs e)
{
foreach (UltraGridRow row in CustomerMarkUpGrid.Selected.Rows)
{
CustomerMarkUpEntity SelectedCustomerMarkUp = CustomerMarkUpCollection[row.Index];
CustomerMarkUpCollectionToDelete.Add(SelectedCustomerMarkUp);
}
DeleteCustomerMarkUp();
}
private void DeleteCustomerMarkUp()
{
DataAccessAdapter adapter = new DataAccessAdapter();
foreach (CustomerMarkUpEntity cme in CustomerMarkUpCollectionToDelete)
{
CustomerMarkUpCollection.Remove(cme);
adapter.DeleteEntity(cme);
}
adapter.Dispose();
}
Again...its only a problem on the last eneity.
Let me know if there is something that i am doing wrong.
Thanks