Problem adding new records to a grid

Problem adding new records to a grid

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


talanx posted on Wednesday, September 23, 2009

I have a parent child form and the child part is in a grid.  I can enter new records using the new record area at the bottom of the grid.  That works fine.  However, when I'm done adding records and I have focus in the new record area of the grid (have not typed anything in it), then I set focus to a different control, such as a textbox... I lose my first new record I just entered and it keeps that last new record that was in the new record area of the grid.  It's seems like it's getting rid of the wrong grid record.  Instead of getting rid of that last record (new area) it's getting rid of my first new record I entered.

Example:  Lets say I have a parent with three children, line numbers:

1

2

3

Now, I enter two more children, line numbers:

4

5

And, I'm sittng in the new record area.  Then I click on a textbox... 4 will disappear and 6 (new record area) will now be a record.  ?

I've been messing with this for a few days now.  I'm currently using VB 2008 with CSLA version 2.1

Do you think I need to upgrade CSLA?

Any direction is appreciated.

Rick

ajj3085 replied on Thursday, September 24, 2009

I think there are known databinding issues in that version. The latest version if you're targeting .Net 2 would be most current 3.0.x release. I see you're using VS2008 though.. so you could make the jump to 3.7.x. I'm not sure if there were any databinding fixes between 3.0 and 3.7.

JonnyBee replied on Sunday, September 27, 2009

Hi,

Are you using filteredBindingList or SortedBindingList?

There's a few bugs fixed here n version 3.8.0 so you should refresh your code (these are "standalone" classes that you can do a refresh on).

/jonnybee

talanx replied on Tuesday, September 29, 2009

Thanks! The upgrade to 3.5 worked!  However, now I've been having a problem with the N level Undo feature.  If I make changes to a record in the grid then set focus to a different record in the grid I can't seem to cancel my changes to the previous record.  I've spend a couple of hours today looking at the forums on this topic, with no real resolution, unless I missed it.  It's not that huge of a problem because I can make a call to the database for a fresh copy of the business object when the user clicks on the cancel button, however it would be nice without that call to the database.  If you know the solution to this or the thread, that would be great to have.

The N-Level Undo is a good feature but I would rather have the object return to it's original values when cancel is clicked.  I don't want to disable the Undo because I need my objects to work properly, particularly in a grid.  And, I don't want to alter anything in the CSLA framework because it may cause upgrading issues in the future.

Rick

ajj3085 replied on Wednesday, September 30, 2009

Glad to hear.. but is there a reason you only upgraded to 3.5, when 3.7.x is the latest version you could use?

What you're seeing with the grid is how windows databinding works. Once you leave the row, the changes are committed to the object in memory. If you need to cancel row edits, you need to press ESC BEFORE clicking out of the row.

This is how all grids work in windows, BTW, so its probably a good idea to stick with it.

You might be able to work around this... but then you run the risk of upsetting the delecate data binding rules and have your grid behave in very odd ways (not to mention, how would you allow canceling a row after you clicked out?)

Copyright (c) Marimer LLC