New Posts New Posts RSS Feed: Create Entity
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Create Entity

 Post Reply Post Reply
Author
Linguinut View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Jun-2007
Location: United States
Posts: 394
Post Options Post Options   Quote Linguinut Quote  Post ReplyReply Direct Link To This Post Topic: Create Entity
    Posted: 08-Aug-2007 at 1:16pm

The Person module based on the Person table in the tutorial database seems to be working.  I can navigate through the data.  If I try to delete one of the entities the program appropriately states that I am not allowed to do so (see deletion guard of entity class).  If I try to add a new entity, I get the following error:

No row can be added to a DataGridView control that does not have columns. Columns must be added first.

Huh?!?  This error comes directly from the EntityBindingSource class in the IdeaBlade.Cab.UI project (a no touchy project).  There are no DataGridViews involved in my new Person view.  I do not understand why this error is popping up.  Makes no sense.

Bill

 

 

 

Back to Top
Linguinut View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Jun-2007
Location: United States
Posts: 394
Post Options Post Options   Quote Linguinut Quote  Post ReplyReply Direct Link To This Post Posted: 09-Aug-2007 at 9:07am
Btw, the Person module is my own creation within Cabana.  Everything works except adding a new entity.  Here is the code block from EntityBindingSource.cs in IdeaBlade.CAB.UI within which the error occurs:
 
public static void InsertEntity(BindingSource pSource, Entity pEntity, Entity pInsertAfterEntity) {
    if ( pSource.DataSource == null || !( pSource.DataSource is IList ) ) return;
    IList list = (IList) pSource.DataSource;
    if ( list.IsReadOnly ) return; // can't insert
   
    int insertPoint = 1 + pSource.IndexOf(pInsertAfterEntity);
    if ( insertPoint > 0 ) {
        pSource.Insert(insertPoint, pEntity);
    } else {
        insertPoint = pSource.Add(pEntity);
    }
    pSource.Position = insertPoint;
}
 
The red highlighted line is the error maker.  What am I missing?
 
Bill
Back to Top
Bill Jensen View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 31-Jul-2007
Location: United States
Posts: 229
Post Options Post Options   Quote Bill Jensen Quote  Post ReplyReply Direct Link To This Post Posted: 09-Aug-2007 at 9:44am
Thanks for the report, Bill.  We'll take a look at this as soon as we can.
 
Bill J.
Back to Top
Linguinut View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Jun-2007
Location: United States
Posts: 394
Post Options Post Options   Quote Linguinut Quote  Post ReplyReply Direct Link To This Post Posted: 13-Aug-2007 at 5:53pm
I am getting back to this issue, again, this evening.  I have briefly reviewed my code and I am not seeing what might be causing this exception to occur.  There are no datagridview controls in the module, so no columns or rows need to be added.  I would assume by reading the comments in the code that the method is supposed to add an entitybindingsource to the workitem.  The error description doesn't seem to correspond to what the method is actually doing.  Well, I am still confused on this issue.  Can anyone help with this?
 
Thanks!
Bill
Back to Top
Bill Jensen View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 31-Jul-2007
Location: United States
Posts: 229
Post Options Post Options   Quote Bill Jensen Quote  Post ReplyReply Direct Link To This Post Posted: 14-Aug-2007 at 3:07pm

Actually, the code is adding a new instance of the entity (Person) to the binding list.  I suspect the 

pSource.Insert(insertPoint, pEntity)
 
call is throwing an exception that is being caught somewhere that thinks you're trying to add an entity to a GridView.
 
Place a breakpoint on the Insert() call and look at the stack trace.
 
Bill J.
Back to Top
Linguinut View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Jun-2007
Location: United States
Posts: 394
Post Options Post Options   Quote Linguinut Quote  Post ReplyReply Direct Link To This Post Posted: 14-Aug-2007 at 3:26pm
"   at System.Windows.Forms.DataGridViewRowCollection.InsertInternal(Int32 rowIndex, DataGridViewRow dataGridViewRow, Boolean force)\r\n   at System.Windows.Forms.DataGridView.DataGridViewDataConnection.ProcessListChanged(ListChangedEventArgs e)\r\n   at System.Windows.Forms.DataGridView.DataGridViewDataConnection.currencyManager_ListChanged(Object sender, ListChangedEventArgs e)\r\n   at System.Windows.Forms.CurrencyManager.OnListChanged(ListChangedEventArgs e)\r\n   at System.Windows.Forms.CurrencyManager.List_ListChanged(Object sender, ListChangedEventArgs e)\r\n   at System.ComponentModel.ListChangedEventHandler.Invoke(Object sender, ListChangedEventArgs e)\r\n   at System.Windows.Forms.BindingSource.OnListChanged(ListChangedEventArgs e)\r\n   at System.Windows.Forms.BindingSource.InnerList_ListChanged(Object sender, ListChangedEventArgs e)\r\n   at System.ComponentModel.BindingList`1.OnListChanged(ListChangedEventArgs e)\r\n   at IdeaBlade.Util.BindableList`1.OnListChanged(ListChangedEventArgs pArgs)\r\n   at IdeaBlade.Persistence.EntityList`1.OnListChanged(ListChangedEventArgs pArgs)\r\n   at IdeaBlade.Util.BindableList`1.InsertItem(Int32 index, T item)\r\n   at System.Collections.ObjectModel.Collection`1.Insert(Int32 index, T item)\r\n   at System.Collections.ObjectModel.Collection`1.System.Collections.IList.Insert(Int32 index, Object value)\r\n   at System.Windows.Forms.BindingSource.Insert(Int32 index, Object value)\r\n   at IdeaBlade.Cab.UI.EntityBindingSource.InsertEntity(BindingSource pSource, Entity pEntity, Entity pInsertAfterEntity) in C:\\Documents and Settings\\bill\\My Documents\\Visual Studio 2005\\Projects\\AspireTest\\Source\\Infrastructure.IdeaBlade\\IdeaBlade.Cab.UI\\Miscellaneous\\EntityBindingSource.cs:line 133\r\n   at IdeaBlade.Cab.UI.EntityBindingSource.InsertEntity(Entity pEntity, Entity pInsertAfterEntity) in C:\\Documents and Settings\\bill\\My Documents\\Visual Studio 2005\\Projects\\AspireTest\\Source\\Infrastructure.IdeaBlade\\IdeaBlade.Cab.UI\\Miscellaneous\\EntityBindingSource.cs:line 151\r\n   at IdeaBlade.Cab.UI.EntityUIController`1.AddNewItemHandler(Object sender, EventArgs`1 e) in C:\\Documents and Settings\\bill\\My Documents\\Visual Studio 2005\\Projects\\AspireTest\\Source\\Infrastructure.IdeaBlade\\IdeaBlade.Cab.UI\\PageControllers\\EntityUIController.cs:line 389\r\n   at IdeaBlade.Cab.UI.PageNavigatorAdapter.InvokeClickHandlerWithCurrentObject(EventHandler`1 pHandler, Boolean pReturnIfNoCurrent) in C:\\Documents and Settings\\bill\\My Documents\\Visual Studio 2005\\Projects\\AspireTest\\Source\\Infrastructure.IdeaBlade\\IdeaBlade.Cab.UI\\Miscellaneous\\PageNavigatorAdapter.cs:line 268\r\n   at IdeaBlade.Cab.UI.PageNavigatorAdapter.AddNewItemButtonClick(Object sender, EventArgs e) in C:\\Documents and Settings\\bill\\My Documents\\Visual Studio 2005\\Projects\\AspireTest\\Source\\Infrastructure.IdeaBlade\\IdeaBlade.Cab.UI\\Miscellaneous\\PageNavigatorAdapter.cs:line 180\r\n   at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)\r\n   at System.Windows.Forms.ToolStripButton.OnClick(EventArgs e)\r\n   at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)\r\n   at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)\r\n   at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)\r\n   at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)\r\n   at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)\r\n   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)\r\n   at System.Windows.Forms.Control.WndProc(Message& m)\r\n   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)\r\n   at System.Windows.Forms.ToolStrip.WndProc(Message& m)\r\n   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)\r\n   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)\r\n   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)\r\n   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)\r\n   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)\r\n   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)\r\n   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)\r\n   at System.Windows.Forms.Application.Run(Form mainForm)\r\n   at Infrastructure.Shell.ShellApplication.Start() in C:\\Documents and Settings\\bill\\My Documents\\Visual Studio 2005\\Projects\\AspireTest\\Layout\\AspireShell\\ShellApplication.cs:line 117\r\n   at Microsoft.Practices.CompositeUI.CabApplication`1.Run()\r\n   at Infrastructure.Shell.ShellApplication.RunInDebugMode() in C:\\Documents and Settings\\bill\\My Documents\\Visual Studio 2005\\Projects\\AspireTest\\Layout\\AspireShell\\ShellApplication.cs:line 74\r\n   at Infrastructure.Shell.ShellApplication.Main() in C:\\Documents and Settings\\bill\\My Documents\\Visual Studio 2005\\Projects\\AspireTest\\Layout\\AspireShell\\ShellApplication.cs:line 53\r\n   at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)\r\n   at System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)\r\n   at System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly()\r\n   at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)\r\n   at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext)\r\n   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()\r\n   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)\r\n   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)\r\n   at System.Threading.ThreadHelper.ThreadStart()"
Back to Top
Linguinut View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Jun-2007
Location: United States
Posts: 394
Post Options Post Options   Quote Linguinut Quote  Post ReplyReply Direct Link To This Post Posted: 14-Aug-2007 at 3:33pm
This is probably one of the biggest stack traces that I have reviewed.  Honestly, I cannot figure out why a call to insert a row into a datagridviewrowcollection is even involved.  None of the supplied code (IdeaBlade.Cab.UI) was altered.  I am using it as is. 
 
Somewhere in the CAB/DevForce linkage is a datagridview waiting to be filled with a new row.  I just don't know where it exists or where to put it if it needs to exist.
 
Bill
Back to Top
Bill Jensen View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 31-Jul-2007
Location: United States
Posts: 229
Post Options Post Options   Quote Bill Jensen Quote  Post ReplyReply Direct Link To This Post Posted: 14-Aug-2007 at 4:57pm
You're right, it's a big stack trace--Cabana and CAB tend to do that. 
 
You correctly deduce that the top seven lines or so imply that a DataGridView has bound to the binding source and its ListChanged handler is trying to add a row for the new entity.
 
What does your page look like?  Does it have a search capability--i.e., does the page controller inherit from EntitySearchPageController or EntitySearchAndResultsPageController?  If so, it probably has a search view at the top incorporating a grid view.  If you expand the search view, (small down-arrow button at top right) you'll see it.  If you don't have a GridBuilder defined for the Person entity, this grid view will have no columns.  That could be causing the problem.
 
Bill J.
Back to Top
Linguinut View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Jun-2007
Location: United States
Posts: 394
Post Options Post Options   Quote Linguinut Quote  Post ReplyReply Direct Link To This Post Posted: 17-Aug-2007 at 10:04am
Yes, the controller inherits from EntitySearchPageController<Person>.  PeopleGridBuilder defined.  Problem goes away.
 
Thanks.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down