WPF Telerik RadGrid: Adding a new record to the grid

Posts   
 
    
marcjvr
User
Posts: 2
Joined: 25-Aug-2009
# Posted on: 25-Aug-2009 01:39:49   

Hi

I am using version v2.0.50727 of the SD.LLBLGen.Pro.ORMSupportClasses.NET20 component.

I am trying to implement inline "Add" functionality to the Telerik WPF Gridview similar to their demo at:

http://demos.telerik.com/wpf/

Under GridView->Populating with Data->DataBase Updates.

I am binding to an EntityCollection of type ProductEntity and everything works great. But when I try add a new record to the grid using the approach in the Telerik example, I get an exception.

This is my code when adding a new product(same way they are doing it in their demo):

        ProductEntity product = new ProductEntity();

        product.Code = "New";
        product.Description = "New";
        product.ProductType = "New";
        product.PackageType = "New";
        product.UnitWeight = 0;
        product.UnitCount = 0;
        product.UnitOfMeasureId = 0;
        product.UnitsPerPiece = 0;
        product.MinimumPercent = 0;
        product.MaximumPercent = 0;
        product.TareWeight = 0;

        e.NewObject = product;

But I get the following exception:

{"Add a new object to the related collection instead, or use IBindingList.AddNew() on this object."}

at SD.LLBLGen.Pro.ORMSupportClasses.EntityViewBase`1.System.Collections.IList.Add(Object value) at Telerik.Windows.Data.EditableCollectionViewExtensions.AddNew(IEditableCollectionView editableCollectionView, Object newItem) at Telerik.Windows.Controls.GridView.EditContext.AddNew(Object newItem) in c:\Builds\WPF_Scrum\GridView_WPF_2009_Q2_SP1\Sources\Development\Controls\GridView\GridView\GridView\Editing\EditContext.cs:line 520 at Telerik.Windows.Controls.GridView.GridViewDataControl.CreateNewItem() in c:\Builds\WPF_Scrum\GridView_WPF_2009_Q2_SP1\Sources\Development\Controls\GridView\GridView\GridView\GridViewDataControl.cs:line 4243 at Telerik.Windows.Controls.GridView.GridViewDataControl.ShowAddNewRow() in c:\Builds\WPF_Scrum\GridView_WPF_2009_Q2_SP1\Sources\Development\Controls\GridView\GridView\GridView\GridViewDataControl.cs:line 4182 at Telerik.Windows.Controls.GridView.GridViewNewRow.BeginEdit() in c:\Builds\WPF_Scrum\GridView_WPF_2009_Q2_SP1\Sources\Development\Controls\GridView\GridView\GridView\Rows\GridViewNewRow.cs:line 132 at Telerik.Windows.Controls.GridView.GridViewDataControl.BeginInsert() in

Any ideas as to how can I resolve this?

Thanks for your time

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 25-Aug-2009 10:25:12   

I am using version v2.0.50727 of the SD.LLBLGen.Pro.ORMSupportClasses.NET20 component.

Tha's the .NET version not the runtime librar version, please check this thread: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=7720

marcjvr
User
Posts: 2
Joined: 25-Aug-2009
# Posted on: 25-Aug-2009 16:04:42   

Sorry, the version is 2.6.9.807

SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 25-Aug-2009 20:47:28   

Have you tried adding the new enity to the collection that the grid is bound to ?

Matt