ProDatabinding - then next

Posted by resperger on 07-Aug-2008 08:18

So now I am building a form and have my Data-Set bound to it.

This kind of binding seems to work fine for a browser.

I need to attach Data-fields from a child table to an editor and that does not seem to be possible. I am only allowed to bind a field from the parent table.

Do I in this case have to work with individual temp-tables instead of dataset?

All Replies

Posted by Peter Judge on 07-Aug-2008 08:32

So now I am building a form and have my Data-Set

bound to it.

This kind of binding seems to work fine for a

browser.

I need to attach Data-fields from a child table to an

editor and that does not seem to be possible. I am

only allowed to bind a field from the parent table.

Do I in this case have to work with individual

temp-tables instead of dataset?

You can bind to child tables using the DataMember property.

If you have a PDS of Customer - Order - OrderLine - Item, you can bind to fields in the Item table by setting the DataSource to the binding source, and then the DataMember might be 'Order.OrderLine.Item.ItemDesc'.

-- peter

Posted by robert.baker on 07-Aug-2008 10:50

I had the same question. I understand what you mean but I don't see DataSource or DataMember properties. Will this work for a System.Windows.Forms.TextBox?

Posted by robert.baker on 08-Aug-2008 10:11

I'm sorry but I'm still unclear on the method for this. Could you please elaborate.

Posted by Peter Judge on 08-Aug-2008 10:48

I'm sorry but I'm still unclear on the method for

this. Could you please elaborate.

It looks like the tools don't provide the ability to specify the DataMember in all cases. I tried with an UltraTextEditor and was only able to specify the top-level table.

However, you do this in code. Assuming a PDS with a structure like this:

ePurchaseOrder

-- ePOLine

eItem

You can then manually add the data bindings like such, and voila!

ultraTextEditor2:DataBindings:Add(

'Text',

bindingSource1,

'ePOLine.eItem.ItemName').

-- peter

Posted by robert.baker on 08-Aug-2008 11:07

That helps a lot thank you.

I am getting System.ArgumentException: DataMember property 'my-table' cannot be found on the DataSource. Perhaps I'm try to bind at the wrong time. Either way, thanks a lot for your help.

Posted by Peter Judge on 08-Aug-2008 11:11

I am getting System.ArgumentException: DataMember

property 'my-table' cannot be found on the

DataSource. Perhaps I'm try to bind at the wrong

time. Either way, thanks a lot for your help.

I should note that you need to put that line of code after the call to InitializeComponent() in the constructor.

-- peter

Posted by robert.baker on 08-Aug-2008 11:21

Well, oddly I'm still getting the error. I must have something else wrong. I'll find it. I don't want to take up any more of your time.

I appreciate the help, thanks.

Posted by robert.baker on 08-Aug-2008 12:02

Ok, sorry, but I do have another question.

Do I need to add to the DataSource or DataMember properties for the BindingSource? I put that line of code in the constructor like:

InitializeComponent().

bindingSource1:Handle = dataset dsMyDataset:handle.

txtMyTextBox:DataBindings:Add("Text", bindingSource1, "my-table.child-table.description").

I get the error on the first table in the datamember parameter. The dash in the table name couldn't be a problem could it?

Posted by Peter Judge on 08-Aug-2008 12:09

Do I need to add to the DataSource or DataMember

properties for the BindingSource? I put that line of

code in the constructor like:

InitializeComponent().

bindingSource1:Handle = dataset dsMyDataset:handle.

txtMyTextBox:DataBindings:Add("Text", bindingSource1,

"my-table.child-table.description").

I'd add the databinding before assigning the bindingSource Handle (although I suspect it doesn't make a difference).

I get the error on the first table in the datamember

parameter. The dash in the table name couldn't be a

problem could it?

The dash shouldn't be a problem by itself. The problem might be that you're adding the top table at all - the reference should be relative to the top. So, in your case, you just need "child-table.fieldname".

-- peter

Posted by robert.baker on 08-Aug-2008 12:21

Wow, ok...I just read your sample wrong. I somehow thought that you had started with the parent table.

Thanks for being patient.

This thread is closed