When I am refreshing a databinding on a grid I am getting a;
A first chance exception of type 'System.ArgumentException' occurred in Infragistics2.Shared.v10.1.dll
A message box pops up that says "Key Already Exists Paramater Name: Key
The first time I set the databinding it works fine and show the rows, if i try to set it again it blows up. I have tried setting it to nothing first but that didnt work. Its just a simple refresh because the list its bound to may have added or removed rows.
How do I troubleshoot this?
I think refreshing like that is not necessary. If you bind a list to the grid and add or delete items, the grid should show the changes. However, not any list supports that, and more specifically, only IBindingList does.
Instead of binding your list directly do this:
var bindingList = new BindingList<myEntity>(myEntitylist);
grid.DataSource = bindingList;
Now any delete or insert in your original list should immediately be seen on the grid.
If you still want to refresh manually, just call grid.Rows.Refresh(RefreshRow.ReloadData);
I'm not actually deleting items out of my list, I set a deletedflag = True on one of the objects in the list, then I have a property that uses LINQ to return a list of valid items (Not deleted) and bind to that. When I set deletedflag = True to an item, it does not remove from the grid unless I refersh
I use this technique all throughout my project but this particular grid configuration is giving me problems.
I tried what u suggested and got the exact same error.