By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,224 Members | 1,414 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,224 IT Pros & Developers. It's quick & easy.

TabControl Losing Data

P: n/a
I have a TabControl that is on a form that is bound to a DataSet. I bind the
dataset to the form in the Form_Load event. The TabControl has 2 TabPages.
The first TabPage contains a button and a textbox.

Scenario 1:
I call BindingContext(ds.TableName).AddNew(), then I click the button and
that populates some text into the textbox on the first tab. Then I switch
over to Tab2 and back to Tab1. The text that was programatically inserted is
now gone.

Scenario 2:
I do NOT call BindingContext(ds.TableName).AddNew(), then I click the button
and that populates some text into the textbox on the first tab. Then I
switch over to Tab2 and back to Tab1. The text that was programatically
inserted is still there.
I want the form to work like it does in Scenario 2, but without calling
AddNew() my DataSet will not show HasChanges.

Aside from calling BindingContext(ds.tablename).EndCurrentEdit() after
clicking on the button to populate the textbox, is there any way to keep this
data on the form?

PS - I understand that the TabControl does not bind its data to the controls
until each TabPage is shown. Could it be that the TabControl is trying to
re-bind the data on TabPage1 when I come back to it and therefore it shows no
data?
Nov 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
From what I have found, setting each TabPage's BindingContext property equal
to the Form's BindingContext it works. I did this on Form_Load and it
appears to be working as I thought it should.

Aspnot
"Aspnot" wrote:
I have a TabControl that is on a form that is bound to a DataSet. I bind the
dataset to the form in the Form_Load event. The TabControl has 2 TabPages.
The first TabPage contains a button and a textbox.

Scenario 1:
I call BindingContext(ds.TableName).AddNew(), then I click the button and
that populates some text into the textbox on the first tab. Then I switch
over to Tab2 and back to Tab1. The text that was programatically inserted is
now gone.

Scenario 2:
I do NOT call BindingContext(ds.TableName).AddNew(), then I click the button
and that populates some text into the textbox on the first tab. Then I
switch over to Tab2 and back to Tab1. The text that was programatically
inserted is still there.
I want the form to work like it does in Scenario 2, but without calling
AddNew() my DataSet will not show HasChanges.

Aside from calling BindingContext(ds.tablename).EndCurrentEdit() after
clicking on the button to populate the textbox, is there any way to keep this
data on the form?

PS - I understand that the TabControl does not bind its data to the controls
until each TabPage is shown. Could it be that the TabControl is trying to
re-bind the data on TabPage1 when I come back to it and therefore it shows no
data?

Nov 23 '05 #2

P: n/a
ASPNot,
I have a TabControl that is on a form that is bound to a DataSet. I bind
the
dataset to the form in the Form_Load event. The TabControl has 2
TabPages.
The first TabPage contains a button and a textbox.

From what I have found, setting each TabPage's BindingContext property
equal
to the Form's BindingContext it works. I did this on Form_Load and it
appears to be working as I thought it should.

Than this is a greath catch because this is a long existing problem

:-)

Cor
Nov 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.