CSLA .NET

From Rockford Lhotka's Expert C# 2008 and VB 2008 Business Objects books

Trying to Use One DataSource for ReadOnly List with Details Page Update

rated by 0 users
This post has 2 Replies | 1 Follower

Top 500 Contributor
Posts 29
andrewrajcoomar Posted: Sun, Nov 30 2008 4:25 AM

I am a brand new user of this framework (excellent, excellent work Rocky). In addition, am writing my first Windows app having worked exclusively on web before.

Hoping someone can point me here. This is my situation:

I have some reference data tables that are very small (< 100 rows) and have a requirement to load all the records when the form load. My UI consists of TabControl control with two pages. Page1 contains a grid and Page2 is the Details page. The Grid is readonly. When a row selection is made from the grid, Page2 receives focus and data should be updatable. No deletes are allowed. Also, Page2 should allow for new data to be added.

I am binding the grid like this:

Me.ChartFieldOverrideListBindingSource.DataSource = New SortedBindingList(Of ChartFieldOverrideInfo)(chartFieldOverrideList)

ChartFieldOverrideList inherits from ReadOnlyListBase

Is this the correct approach for such an implementation? Ideally, when the user interacts with the data on Page2, just one record should be affected at a time. Going this way, it seems I will have to call Save manually, and handle a single row update. I am having crazy thoughts of using the row to populate my ChartFieldOverride object, and then call my methods from within that class to insert/update the row. Another thought I have it to bind Page2 to the single object class ChartFieldOverride and then call Fetch each time a selection is made from Page1. But then I'd have to Fetch on Page1 also, to refresh, when a new record is added via Page2. This all seems like a lot of traffic.

It appears, the whole workup looks like the Edit Project task in Project Tracker, except that I have the two forms combined into one.

Please, any advise.

Thanks, Andrew:

Top 10 Contributor
Posts 7,309

You have perhaps three options (with various sub-options).

  1. Make ChartFieldOverrideList an editable list, so you can edit its items and call Save() on the whole list.
  2. Make ChartFieldOverrideList a dynamic list (inherit from EditableRootListBase), so you can edit its items an save each one individually (by calling SaveItem() on the list).
  3. Make ChartFieldOverrideList a read-only list, then use an editable root to edit each item as the user selects it
    1. After the editable root has been saved
      1. reload the ChartFieldOverrideList entirely - which will get not only your edit, but other user's edits too
      2. call a method on ChartFieldOverrideList to merge in the new data from the editable root (assuming the editable root contains all data required to populate an item in the list) (this won't catch changes from other users)
      3. call a method on ChartFieldOverrideList to have it use a Command object to reload the new data for the one item that you know has changed (this won't catch changes from other users)

 

Rocky

Top 500 Contributor
Posts 29

Thanks Rocky.

I went with a combination of 2; readonlylist from which the user can select/delete, and then I use the selection to return a businessbase object.

However, I now have another issue, which I have posted here:

http://forums.lhotka.net/forums/post/28983.aspx

When I am adding new data I bind to a new basebusiness object thru a click event. The issue is, any textbox that I enter a value into requires a double-tab for me to exit it. This behaviour is not the same for edits, for which I am again binding to the same base business object, except that the GetMyData method was called, instead of NewData.

Really appreciate your help, sir.

Thanks,

Andrew

 

Page 1 of 1 (3 items) | RSS

Please contact Magenic for your .NET consulting
and CSLA .NET mentoring needs.
Please consider making a donation to help support the ongoing development of CSLA .NET.

Make donation through PayPal - it's fast, free and secure!
Why donate?
Copyright (c) 2006-2010 Marimer LLC. All rights reserved.
Email admin@lhotka.net for support.
Powered by Community Server (Non-Commercial Edition), by Telligent Systems