textbox data binding

B

Balcity

please help me. when i bind data to a textbox like this:

txtStudentID.DataBindings.Add("Text",myDataSet,"Students.ID");

it doesn't bind, this TextBox is on the second tab page of tab control so
when containing form is opened it is not bound but when activate the second
page on which this textbox resides the data is bound. i am missing
something.
 
D

Dominic Paquette

I think it may have something to do with the fact that a container control
such as a panel, from or tabPageControl each have their own BindingContrext.
Do you have a code example?

I never tried this but maybee if you do something like this in the formLoad:

this.MyTabPage.BindingContext[MyDataSet] = this.BindingContext[MyDataSet];
 
U

Ulrich Sprick

Hi,
I think it may have something to do with the fact that a container control
such as a panel, from or tabPageControl each have their own BindingContrext.

That's it. Make your Tab pages use the binding context of e.g. the form.

this.Tabpage1.BindingContext = this.BindingContext;
this.Tabpage2.BindingContext = this.BindingContext;

HTH, ulrich

Dominic Paquette said:
I think it may have something to do with the fact that a container control
such as a panel, from or tabPageControl each have their own BindingContrext.
Do you have a code example?

I never tried this but maybee if you do something like this in the formLoad:

this.MyTabPage.BindingContext[MyDataSet] = this.BindingContext[MyDataSet];
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top