textbox data binding

  • Thread starter Thread starter Balcity
  • Start date Start date
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.
 
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];
 
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];
 
Back
Top