[RESOLVED] Problem get datagrid to work

[RESOLVED] Problem get datagrid to work

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


vbdotnetguy posted on Wednesday, September 20, 2006

Hello everyone... this is my first time working with the CSLA and my first post.  Here's my problem

I have table A which would be the parent and table B being the child.  I'm trying to do something similar to what Rocky did with the project tracking application. 

I have a class called TimeCard which is the inherits BusinessBase which has a member that links to the
TimeCardEntries class (BusinessListBase).  Then I have a class call TimeCardEntry.  I  have a DataGridView that I want the user to be able to add, edit and delete rows without the use of buttons.  However I keep getting all kinds of exceptions.  I'm very confused now, so any help would be greatly appreciated.

The exception occures when I try typing a value in to a cell.  I get the DataGridView Default Error Dialog with an exception of IndexOutOfRangeException: Index 0 does not have a value

vbdotnetguy replied on Wednesday, September 20, 2006

Ok well I got pass the exception however now the data grid view won't keep the previous value meaning... if I type in all the information tab to the next row and say i click back on the previous row it goes away.  However if I enter two rows go to the first one or click outside of the data grid view I lose the second.  Then if I try and enter a new row again I get the following error Operation is not valid due to the current state of the object. 


what am I doing wrong?

ajj3085 replied on Thursday, September 21, 2006

In your collection class, are you overriding AddNewCore?  It should look similar to this:

protected override AddNewCore() {
    TimeCardEntry entry;
 
    entry = TimeCardEntry.NewTimeCardEntry();
    OnAddingNew( new AddingNewEventArgs( entry ) );

    Add( entry );

   return entry;
}

Copyright (c) Marimer LLC