We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Deleting rows in GridDataboundGrid

Clay, I have 6 Total Rows. Out of which I entered data in 2nd, 4th and 6th row. Now I want to delete 2nd, 4th and 6th row. I am getting the following error at this.gridDataBoundGrid1.Binder.RemoveRecords(r.Top - 1, r.Bottom - 1); By using this I get a message saying that "There is no row at position 5" Please let me know why. Here is my gridDataBoundGrid1_RowsDeleting Code. private void gridDataBoundGrid1_RowsDeleting(object sender, Syncfusion.Windows.Forms.Grid.GridRowRangeEventArgs e) { //e.Cancel = true; if(!indeleting) { this.gridDataBoundGrid1.BeginUpdate(); this.gridDataBoundGrid1.Binder.SuspendBinding(); indeleting = true; GridRangeInfoList rangeList = this.gridDataBoundGrid1.Selections.GetSelectedRows(true, false); if(rangeList.Count > 1) { this.gridDataBoundGrid1.Selections.Clear(); int nRanges = rangeList.Count; for(int i = 0; i < nRanges; ++i ) { GridRangeInfo r = rangeList[0]; int bottom = r.Bottom; for(int j = 1; j < rangeList.Count; ++j) { if(rangeList[j].Bottom > bottom) { r = rangeList[j]; bottom = r.Bottom; } } rangeList.Remove(r); this.gridDataBoundGrid1.Binder.RemoveRecords(r.Top - 1, r.Bottom - 1); } e.Cancel = true; } indeleting = false; this.gridDataBoundGrid1.Binder.ResumeBinding(); this.gridDataBoundGrid1.EndUpdate(); } } Thanks Satish

1 Reply

AD Administrator Syncfusion Team April 19, 2004 08:48 AM

Hi Satish, Please make sure that your DataTable has proper rowcount (6 rows). Here is a sample that has 6 rows. On selecting the 2nd, 4th and 6th and hitting delete seems to work fine. Do you see the problem in this sample too? Regards, Jay N.

Loader.
Live Chat Icon For mobile
Up arrow icon