Binding fields to grandchild collection help pls

Posts   
 
    
dma550
User
Posts: 20
Joined: 11-Feb-2006
# Posted on: 23-Feb-2006 02:17:08   

Hi there

I have successfully set up llblgen to represent my data structure, I am using the self servicing adapter and vb.net 2005.

It looks like this:

Bill to Organization (A) | Subscription(s) | |----------------------| Bill To Org Ship to Org

I load the organization(A) and the relationships work out so I can look at SubBillTo, and get a collection of subscriptions that belong to the organization. If I look at BillToOrg.SubBillto(10) (10th row in the collection) I get properties "ShipToOrg" which is the child collection, and describes the Organization related via the "ship to" relationship. All looks happy. I can pop this relationship up with a devexpress grid, and it displays all the levels, and I can navigate, save, etc.

Now for the tough part: The actual data entry needs to happen on a form with fields. I have setup the databinding and it works for the Organization(A) side, and it works for the Subscription. What I can't figure out how to do is bind the related organization from the "ship to" level, the grand child.

This is how the subscription is bound:

        Me.txtRecSubscriptionID.DataBindings.Add(New Binding("Text", OrgSubscriber.SubBillTo, "SubscriptionId"))
        Me.txtRecRecipient.DataBindings.Add(New Binding("Text", OrgSubscriber.SubBillTo, "Recipient"))

What I think I want to do is bind the text fields to the subscriber "ship to" organization information. This is what I tried:


    Me.cmbRecZip.DataBindings.Add(New Binding("Text", OrgSubscriber.SubBillTo.organization, "Zip")) ' HERE, how to get this relationship?

In debug mode, I can print OrgSubscriber.SubBillTo(1).OrgDeliverTo.Zip and see the zip code. Can someone give me a tip as to how I could bind this text box to the entity?

Thanks!

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 23-Feb-2006 08:07:27   

OrgSubscriber.SubBillTo is a collection so I think you should specify an index to bind to the inner organization object. OrgSubscriber.SubBillTo.organization doesn't exist, but ((Subscription)OrgSubscriber.SubBillTo[index]).organization exists.

Please refer to the following threads for help: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=4493 http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=5212

dma550
User
Posts: 20
Joined: 11-Feb-2006
# Posted on: 23-Feb-2006 15:45:07   

Thanks Walaa

Here's my thought; I was hoping to bind the text boxes once, and have them update as I traversed the object. If I move to subscription(2), I was hopeful that it would also move the grand child pointers as well.

The way the collection works, if there is a subscription that has 10 ship to's, the subscription collection will have 10 rows in it. Depending upon how the user hops around (grid/clicking on next/prev buttons) they change their position with the subscription collection. As the organization is on a 1:1 with the subscription, they are shown edit fields that pertain to not only the subscription (costs/details) but the ship to organization.

So, if I bind using the index of the subsription collection, which can be variable based upon which subscription they are currently working on, will I have to rebind each and every time a move is made?

Thanks, DMA

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 23-Feb-2006 16:29:15   

I think you should add your Textboxes or comboBoxes databinding in the dataGrid selectedIndexChanged event (whatever is the corresponging event)

So you will add code like this:

Me.cmbRecZip.DataBindings.Add(New Binding("Text", ((Subscription)OrgSubscriber.SubBillTo[index]).organization , "Zip"))

Also please refer to the following informative thread: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=5212

dma550
User
Posts: 20
Joined: 11-Feb-2006
# Posted on: 23-Feb-2006 16:34:57   

Thanks Walaa

Looks like I do need to bind on each child change.

What I think was spoiling me was Devexpress would do this all for you when you expanded the levels of the grid.

Thanks again for the quick support!

-DMA