binding a ds to a text box control [* Resolved *]
Hello
I am having a lot of trouble with binding a ds to a text box control.
I have a query SELECT Name, Address, PostCode FROM Customer
This query fills the dataset. This works fine as l have tested this in my web service. The xml displays the name, address, and postcode.
But l get my error message when l try and bind this to the text box control. I have tried many things and l now that the syntax is right. Am l missing something.
//Error Message - Cannot create a child list for field Customer
txtName.DataBindings.Add("Text",ds,"Customer.Name");
txtAddress.DataBindings.Add("Text",ds,"Customer.Address");
txtPostcode.DataBindings.Add("Text",ds,"Customer.PostCode");
many thanks in advance,
Steve
Re: binding a ds to a text box control
The problem has been solved. This is what i did?
Code:
txtName.DataBindings.Add(new Binding("Text",ds.Tables[0],"Name");
Another question. Why do l need ds.Tables[0]. I know that the index point to the first table. And the dataset has only been filled with one table "customer".
I tried this but this method, but did not work.
Code:
txtName.DataBinding.Add(new Binding("Text",ds.Tables["Customer"],"Name");
Can you explain why ds.Tables["customer"] does not work?
Thanks in advance,
Steve