Updating data in listview

Updating data in listview

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


Pascal Hendriks posted on Monday, July 31, 2006

Hi all,

I'm new to CSLA programmaing and have creaqted a sample application just by copying the projecttracker solution and manipulated SQL-commands, etc.

Just pretend my objects are of type X.

Now I have a read-only list: ListX
A read-only (info) object: XInfo
And an editable object: XObject

I have a form with a listview, it's filled by the ListX.
And a couple of edit-boxes binded with teh properties of a instance of XObject.
Now when I edit XObject and pusgh the save button all goes fine, the editboxes are updates, everything is stored in the database, but my listview isn't updated.

Can someone tell me what I do wrong?

Kind regards,

Pascal

burmajam replied on Monday, July 31, 2006

Hi Pascal,

You are not doing wrong anything! So, what is the problem than? Take a look at what is binded to your listview. It is collection (ListX) of XInfo. It is fetched and binded as it were in database. Than you made XObject and inserted it in database. But! Who told collection to refresh it's data?

Don't let the fact that you are using the same data from database confuse you! In CSLA you are not dealing with database data directly, but with objects! Change in a database doesn't mean that object that fetched data from it is changed also!

I hope that this will help you understand the way framework works


Pascal Hendriks replied on Monday, July 31, 2006

Thanks for your answer.

Still I have a question.

When I want the behaviour I suggested what do I have to do with the framework to tell all list/controls, etc that an item has changed, so they have to reload their (partial) data?

 

Kind regards,

 

Pascal

Brian Criswell replied on Monday, July 31, 2006

The listview is not a data bound control.  You will need to reload it or handle the ListChanged event on the underlying list and modify the contents of the listview appropriately.  Alternatively, you could use a DataGridView in read-only mode.

Pascal Hendriks replied on Tuesday, August 01, 2006

Hello,

Now I have used a gridview, but still when I change a value of a property and save the object I still don't see the changes in the gridview.

I have for Example a list of exployees, called EmployeeList.
And an editable object Employee.

When I select an item in the grid I pass the real object to the edit controls.


When I'm done editing I call clone..save (like in the projecttracker example).
At that moment there is no reload by the gridview.
I realy don't want a complete reload, cause the're about 10000 records in the database.
Can somebody tell me what I am doing wrong?

Kind regards,

Pascal

 

Brian Criswell replied on Tuesday, August 01, 2006

If you are doing that, then you will need to update all references to your EmployeeList to point to the cloned EmployeeList, because your pre-clone EmployeeList has not changed.

Copyright (c) Marimer LLC