Grid binding and add row with csla 2.0.3

Grid binding and add row with csla 2.0.3

Old forum URL: forums.lhotka.net/forums/t/1532.aspx


figuerres posted on Wednesday, October 18, 2006

Hi, can anyone tell me if the 2.0.3 source has a problem with gridviews?

I found a note and a downbload from 2003 that talks about chnages -- seems like they would be in the 2.0.3 code by now.

I am trying to use the Developer Express XtraGrid to allow users to edit and add rows.

if I add a row in code that row seems to edit ok.

but a GUI attempt at an add fails W/o any error messages.

? anyone know the way to fix this ?

 

figuerres replied on Wednesday, October 18, 2006

more info:  after reading some posts I am trying a few chnages,

CurrentSale = MCS.FitPro.Library.Invoice.NewInvoice(0, True)
CurrentSale.Invoicelineitem.AllowEdit =
True
CurrentSale.Invoicelineitem.AllowNew = True
CurrentSale.Invoicelineitem.AllowRemove = True
CurrentSale.BeginEdit()
CurrentSale.Invoicelineitem.Add(
Me.CurrentSale.Invoicelineitem.NewLineItem())Me.InvoiceBindingSource.DataSource = Nothing
Me.InvoicelineitemBindingSource.DataSource = Me.CurrentSale.Invoicelineitem
Me.InvoiceBindingSource.DataSource = CurrentSale

this all runs but now when I start to edit I get an exeption. Here is part of the trace:

System.MissingMethodException was unhandled
  Message="Constructor on type 'MCS.FitPro.Library.InvoiceLineItem' not found."
  Source="mscorlib"
  StackTrace:
       at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
       at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
       at System.Activator.CreateInstance(Type type, Object[] args)
       at System.SecurityUtils.SecureCreateInstance(Type type, Object[] args)
       at System.ComponentModel.BindingList`1.AddNewCore()
       at System.ComponentModel.BindingList`1.System.ComponentModel.IBindingList.AddNew()
       at System.Windows.Forms.BindingSource.AddNew()
       at System.Windows.Forms.CurrencyManager.AddNew()
       at DevExpress.Data.CurrencyDataController.AddNewRow()
       at DevExpress.XtraGrid.Views.Grid.GridView.OnActiveEditor_ValueModified(Object sender, EventArgs e)
       at DevExpress.XtraEditors.Repository.RepositoryItem.RaiseModified(EventArgs e)
       at DevExpress.XtraEditors.BaseEdit.RaiseModified()
       at DevExpress.XtraEditors.BaseEdit.set_IsModified(Boolean value)
       at DevExpress.XtraEditors.BaseEdit.OnEditValueChanging(ChangingEventArgs e)
       at DevExpress.XtraEditors.BaseEdit.set_EditValue(Object value)
       at DevExpress.XtraEditors.TextEdit.OnMaskBox_ValueChanged(Object sender, EventArgs e)
       at DevExpress.XtraEditors.Mask.MaskBox.RaiseEditTextChanged()
       at DevExpress.XtraEditors.Mask.MaskBox.MaskStrategy.SimpleStrategy.DoAfterTextChanged(EventArgs e)
       at DevExpress.XtraEditors.Mask.MaskBox.OnTextChanged(EventArgs e)
       at System.Windows.Forms.TextBoxBase.WmReflectCommand(Message& m)

 

So ither I used the wrong template and .AddNew() is not there or ????

 

figuerres replied on Wednesday, October 18, 2006

I think when I used codesmith I generated
Invoice - EditableRoot
InvoiceLineItems - EditableChildList
InvoiceDetails - EditableChild

does that sound right??

 

figuerres replied on Thursday, October 19, 2006

Ok found and fixed!

 

notes:  the Codesmith templates from codeplex download are not adding an override that was needed.  the template has the code, but it's not added.

override CoreAddNew() was missing and the contructor needed .AllowAdd = True

 

Martin Sørensen replied on Friday, November 24, 2006

Hi. I have the same problem... can you help me correct the template... where do I chance this ???

Regards Martin

 

Copyright (c) Marimer LLC