Deleting the last item of a DataboundGrid

Hi, I've got a DataboundGrid which I bind to an ArrayList. I've got a button which deletes the currently selected row (using DeleteRecordsAtRowIndex, or deleting from the ArrayList and rebinding). If the row being deleted is the last row in the grid, I always get a System.ArgumentOutOfRangeException when I try to select another row. I'm guessing the problem is the models selected index, or current cell. Is this a bug? Or is it part of my responsibilities to check when I delete or rebind that the current cell / selection is valid? Thanks, Sue

1 Reply

AD Administrator Syncfusion Team February 25, 2003 12:46 PM UTC

We will look into this. It sounds like something that should not happen. Here is a work-around that avoids the problem until we get it fixed.
private void button1_Click(object sender, System.EventArgs e)
{
	int row = this.gridDataBoundGrid1.Binder.PositionToRowIndex(this.gridDataBoundGrid1.Binder.CurrentPosition);;
	if(row == this.gridDataBoundGrid1.Model.RowCount && row > 0)
	{
		this.gridDataBoundGrid1.CurrentCell.MoveUp(1, false);
	}
	this.gridDataBoundGrid1.DeleteRecordsAtRowIndex(row,row);
}

Loader.
Up arrow icon