This is a migrated thread and some comments may be shown as answers.
Problem with Delete row
3 Answers 297 Views
This is a migrated thread and some comments may be shown as answers.
dootndo2
Top achievements
Rank 1
dootndo2 asked on 15 Oct 2007, 04:40 AM
I noticed that some other folks were having a similar issue, but not the same issue I am having.  I am binding my RadGridView to a Generic List.  When I delete the item in the Generic List and rebind the row doesn't remove until I scroll the deleted row out of view and then back into view. 

The item is removed, but the physical row is still on the grid.  It throws the following exception:

The following exception occurred in the RadGridView:  
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.  
Parameter name: index  
   at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)  
   at System.ThrowHelper.ThrowArgumentOutOfRangeException()  
   at System.Collections.Generic.List`1.System.Collections.IList.get_Item(Int32 index)  
   at Telerik.WinControls.UI.GridViewData.GetValue(Int32 boundColumnIndex, Int32 columnIndex, Int32 rowIndex)  
 

Sample Code to reproduce the error:

' in form load, the grid is bound to the genericList  
private sub frm_frmLoad()  
  Me.radGridView.DataSource = genericList  
End Sub 
 
public sub RemoveItemFromList(ByVal customItemToRemove as CustomItems)  
  ' remove item from the List(Of CustomItems)  
  If genericList.Contains(customItemToRemove) Then 
    genericList.RemoveAt(genericList.IndexOf(customItemToRemove))  
  End If 
 
  ' rebind to   
  Me.radGridView.DataSource = genericList  
End Sub 

I am currently using Q1 2007 with VS2005 SP1.

Thanks for a great product and any thoughts on this.

Dennis

3 Answers, 1 is accepted

Sort by
0
Julian Benkov
Telerik team
answered on 15 Oct 2007, 08:41 AM
Hello Dennis,

Thank you for writing.

You can use BindingList generic list for your objects. When you remove a row from the list, then fired ListChanged event and grid refresh automatically. For this scenario we will make additional improvements in our upcoming release.

Please download and use the Q2 SP1 release. Remember to uninstall the current version of the product before installing the new one. Also, when you're finished installing, make sure the GAC only contains DLLs bearing the latest version of the product.

Please contact us again if we could be of any further assistance.

Best wishes,
Julian Benkov
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Louis
Top achievements
Rank 1
answered on 15 Oct 2007, 06:15 PM
So how one can do to delete a batch of rows when multiple row is set to true?

when i remove a row the SelectedRows is cleared.

Is there a way to delete a batch of rows?

thanks

edited: ok never mind, just recopy the collection of selectedRows before deleting like this...
List<GridViewRowInfo> selrows = new List<GridViewRowInfo>();  
for (int i = 0; i < grdSearchResults.SelectedRows.Count; i++)  
{  
  //if row is not of type GridViewRowInfo then it may be he header or filter row so continue  
  if (grdSearchResults.SelectedRows[i] is GridViewFilteringRowInfo ||   grdSearchResults.SelectedRows[i] is GridViewHeaderRowInfo)  
  continue;  
  selrows.Add(grdSearchResults.SelectedRows[i]);  

Is there another way of checking for rows hat can actually be deleted?
0
Julian Benkov
Telerik team
answered on 16 Oct 2007, 11:09 AM
Hi Louis ,

Your solution with a copy of the collection is adequate in this situation.

We continue to improve RadGridView and in our upcoming release different rows collection will be better synchronized.

Thank you for the feedback. Please contact us again if we could be of any service.

Best wishes,
Julian Benkov
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Asked by
dootndo2
Top achievements
Rank 1
Answers by
Julian Benkov
Telerik team
Louis
Top achievements
Rank 1
Share this question
or