Hello,
I noticed that adding a new row with the Add ... button is not possible when databinded to a generic List<>
I wonder why the Infragistics team didn't implement this?
Or is it a feature and is it going to be implemented?
Greetings
This is not something that it is possible for us to implement, because it's a function of the List, not the grid. List does not have an add method that takes no parameters, and the grid can't know how to create an object that belongs in the List. If you want to bind the grid to a generic list that supports adding, I recommend using BindingList<> instead of List<>.
Ok, i changed all my List<> businessentities to BindingList<> but when i hit the button with "BindingList'1" on it i still get a message:
"Unable to add a row: Row insertion not supported by this datasource."
BindingList doesn't solve the problem :(
PS: My view has the following code
#region IOvzRelatieAdresView
{
set
// adresBindingSource.DataSource = value.Adressen;
}
get
#endregion IOvzRelatieAdresView
Hm. That's off. What happens if you call the Add (or maybe it's AddNew) method on your binding list in code? Does that work?
Odd..
The Add and the AddNew both give an exception on my BindingList, something to do with Types..
Unable to cast object of type 'System.RuntimeType' to type 'System.ComponentModel.BindingList`1[Nova.Relatie.Interface.BusinessEntities.Adres]'.
base.OnViewReady();
View.Persoon.Adressen.Add(new Adres(AdresType.BezoekAdres, "Kalverstraat", 1, string.Empty, "1234AA", "Amsterdam"));
View.Persoon = _persoon;
I just realised i did the add wrong, now i tryed it directly on the object.. and that works perfectly without an exception
Instead of using the setter property of the View..
So it fails whenever the object is databinded to the grid
One obvious reason why the BindingList could not add is if the objects in your list don't have a public parameterless constructor. Not sure why you would get an error message like that, though. Maybe the call stack of the exception can point you in the right direction.
I just realized that what I wrote doesn't make sense, since you are passing in the object. Are you sure it's the Add method that is raising the exception and not the constructor of your object?
This almost seems like a references issue, like your project has mixed references.
Beyond that, I'm really not sure what the problem could be, but it doesn't seem like it's related to the grid.