Binding a textbox to a dataview

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a textbox bound to a dataview, when I update the text in the textbox no changes take place in the underlying dataset. Why is this??

any answers appreciated, as to due to the underlying structure of the datasets, i.e lots of child tables etc, I cannot use bindingcontext
 
Paul,

If you are not using binding context, then how are you binding to the
data set? The DataBindings collection and the BindingContext classes are
tied together, and you can't really have one without the other.

What exactly are you doing in order to create a data binding?


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Paul Slavin said:
I have a textbox bound to a dataview, when I update the text in the
textbox no changes take place in the underlying dataset. Why is this??
any answers appreciated, as to due to the underlying structure of the
datasets, i.e lots of child tables etc, I cannot use bindingcontext
 
thanks for your reply... heres a bit more detail

I'm binding to a dataview:

this.rgiDataView = new DataView();
this.rgiDataView.Table = this.ds.Tables["ATPBlockOrOL"];
this.rgiNormTxtBox.DataBindings.Add( "text", rgiDataView, "RailGapIndicatorId" );

and I change the view in the textbox based on the currently selected item in a combobox on the same form:

this.rgiDataView.RowFilter = "BlockOrOLId = '" + this.blockIdComboBox.SelectedValue + "'";

when I change the selection in the combobox, the text in the text box changes correctly, but when I change text in the textbox the changes aren't reflected in the dataset. Am I doing something fundamentaly wrong?

If I do exactly the same thing but binding to a datagrid rather than the textbox it updates the dataset correctly


Nicholas Paldino said:
Paul,

If you are not using binding context, then how are you binding to the
data set? The DataBindings collection and the BindingContext classes are
tied together, and you can't really have one without the other.

What exactly are you doing in order to create a data binding?


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Paul Slavin said:
I have a textbox bound to a dataview, when I update the text in the
textbox no changes take place in the underlying dataset. Why is this??
any answers appreciated, as to due to the underlying structure of the
datasets, i.e lots of child tables etc, I cannot use bindingcontext
 
Paul,

When checking the value in the textbox, have you left the focus of the
textbox? The value will not be written to the dataset until the focus is
lost (more specifically, when validation is complete, which usually happens
when focus is lost).


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Paul Slavin said:
thanks for your reply... heres a bit more detail

I'm binding to a dataview:

this.rgiDataView = new DataView();
this.rgiDataView.Table = this.ds.Tables["ATPBlockOrOL"];
this.rgiNormTxtBox.DataBindings.Add( "text", rgiDataView, "RailGapIndicatorId" );

and I change the view in the textbox based on the currently selected item
in a combobox on the same form:
this.rgiDataView.RowFilter = "BlockOrOLId = '" +
this.blockIdComboBox.SelectedValue + "'";
when I change the selection in the combobox, the text in the text box
changes correctly, but when I change text in the textbox the changes aren't
reflected in the dataset. Am I doing something fundamentaly wrong?
If I do exactly the same thing but binding to a datagrid rather than the
textbox it updates the dataset correctly
Nicholas Paldino said:
Paul,

If you are not using binding context, then how are you binding to the
data set? The DataBindings collection and the BindingContext classes are
tied together, and you can't really have one without the other.

What exactly are you doing in order to create a data binding?


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Paul Slavin said:
I have a textbox bound to a dataview, when I update the text in the
textbox no changes take place in the underlying dataset. Why is this??
any answers appreciated, as to due to the underlying structure of the
datasets, i.e lots of child tables etc, I cannot use bindingcontext
 
thanks for replying yesterday Nicholas,

after further debugging, ive discovered that the change is actually taking place in the dataset but the rowstate remains as Unchanged!!!! so when I write back to the database no changes found and hence none are commited.... now i'm even more confused, i'm not accepting changes anywhere before I try and update.... oh well more debugging!!!!
 
thanks for replying yesterday Nicholas,

after further debugging, ive discovered that the change is actually taking place in the dataset but the rowstate remains as Unchanged!!!! so when I write back to the database no changes found and hence none are commited.... now i'm even more confused, i'm not accepting changes anywhere before I try and update.... oh well more debugging!!!!


Paul Slavin said:
In order for the updates to be written from the dataset to the database, i have to hit a save button on the form which ensures that any changed controls have lost focus!!


Nicholas Paldino said:
Paul,

When checking the value in the textbox, have you left the focus of the
textbox? The value will not be written to the dataset until the focus is
lost (more specifically, when validation is complete, which usually happens
when focus is lost).


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Paul Slavin said:
thanks for your reply... heres a bit more detail

I'm binding to a dataview:

this.rgiDataView = new DataView();
this.rgiDataView.Table = this.ds.Tables["ATPBlockOrOL"];
this.rgiNormTxtBox.DataBindings.Add( "text", rgiDataView, "RailGapIndicatorId" );

and I change the view in the textbox based on the currently selected item
in a combobox on the same form:
this.rgiDataView.RowFilter = "BlockOrOLId = '" +
this.blockIdComboBox.SelectedValue + "'";
when I change the selection in the combobox, the text in the text box
changes correctly, but when I change text in the textbox the changes aren't
reflected in the dataset. Am I doing something fundamentaly wrong?
If I do exactly the same thing but binding to a datagrid rather than the
textbox it updates the dataset correctly
:

Paul,

If you are not using binding context, then how are you binding to the
data set? The DataBindings collection and the BindingContext classes are
tied together, and you can't really have one without the other.

What exactly are you doing in order to create a data binding?


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

I have a textbox bound to a dataview, when I update the text in the
textbox no changes take place in the underlying dataset. Why is this??

any answers appreciated, as to due to the underlying structure of the
datasets, i.e lots of child tables etc, I cannot use bindingcontext
 
thanks for replying yesterday Nicholas,

after further debugging, ive discovered that the change is actually taking place in the dataset but the rowstate remains as Unchanged!!!! so when I write back to the database no changes found and hence none are commited.... now i'm even more confused, i'm not accepting changes anywhere before I try and update.... oh well more debugging!!!!
 
thanks for replying yesterday Nicholas,

after further debugging, ive discovered that the change is actually taking place in the dataset but the rowstate remains as Unchanged!!!! so when I write back to the database no changes found and hence none are commited.... now i'm even more confused, i'm not accepting changes anywhere before I try and update.... oh well more debugging!!!!


Paul Slavin said:
In order for the updates to be written from the dataset to the database, i have to hit a save button on the form which ensures that any changed controls have lost focus!!


Nicholas Paldino said:
Paul,

When checking the value in the textbox, have you left the focus of the
textbox? The value will not be written to the dataset until the focus is
lost (more specifically, when validation is complete, which usually happens
when focus is lost).


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Paul Slavin said:
thanks for your reply... heres a bit more detail

I'm binding to a dataview:

this.rgiDataView = new DataView();
this.rgiDataView.Table = this.ds.Tables["ATPBlockOrOL"];
this.rgiNormTxtBox.DataBindings.Add( "text", rgiDataView, "RailGapIndicatorId" );

and I change the view in the textbox based on the currently selected item
in a combobox on the same form:
this.rgiDataView.RowFilter = "BlockOrOLId = '" +
this.blockIdComboBox.SelectedValue + "'";
when I change the selection in the combobox, the text in the text box
changes correctly, but when I change text in the textbox the changes aren't
reflected in the dataset. Am I doing something fundamentaly wrong?
If I do exactly the same thing but binding to a datagrid rather than the
textbox it updates the dataset correctly
:

Paul,

If you are not using binding context, then how are you binding to the
data set? The DataBindings collection and the BindingContext classes are
tied together, and you can't really have one without the other.

What exactly are you doing in order to create a data binding?


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

I have a textbox bound to a dataview, when I update the text in the
textbox no changes take place in the underlying dataset. Why is this??

any answers appreciated, as to due to the underlying structure of the
datasets, i.e lots of child tables etc, I cannot use bindingcontext
 
errr....sorry about the multiple posts msdn was playing up earlier and telling me my post hadn't been receieved!!!!...oh well, in case your interested, i've fixed my problem, the value was changing in the dataset but the rowstate wasn't because I was not explicitly calling endedit on the updated row! that will teach me to try and actually get some work done after lunch time when my brain has shut down!!!

Paul Slavin said:
thanks for replying yesterday Nicholas,

after further debugging, ive discovered that the change is actually taking place in the dataset but the rowstate remains as Unchanged!!!! so when I write back to the database no changes found and hence none are commited.... now i'm even more confused, i'm not accepting changes anywhere before I try and update.... oh well more debugging!!!!


Paul Slavin said:
In order for the updates to be written from the dataset to the database, i have to hit a save button on the form which ensures that any changed controls have lost focus!!


Nicholas Paldino said:
Paul,

When checking the value in the textbox, have you left the focus of the
textbox? The value will not be written to the dataset until the focus is
lost (more specifically, when validation is complete, which usually happens
when focus is lost).


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

thanks for your reply... heres a bit more detail

I'm binding to a dataview:

this.rgiDataView = new DataView();
this.rgiDataView.Table = this.ds.Tables["ATPBlockOrOL"];
this.rgiNormTxtBox.DataBindings.Add( "text", rgiDataView,
"RailGapIndicatorId" );

and I change the view in the textbox based on the currently selected item
in a combobox on the same form:

this.rgiDataView.RowFilter = "BlockOrOLId = '" +
this.blockIdComboBox.SelectedValue + "'";

when I change the selection in the combobox, the text in the text box
changes correctly, but when I change text in the textbox the changes aren't
reflected in the dataset. Am I doing something fundamentaly wrong?

If I do exactly the same thing but binding to a datagrid rather than the
textbox it updates the dataset correctly


:

Paul,

If you are not using binding context, then how are you binding to
the
data set? The DataBindings collection and the BindingContext classes
are
tied together, and you can't really have one without the other.

What exactly are you doing in order to create a data binding?


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

I have a textbox bound to a dataview, when I update the text in the
textbox no changes take place in the underlying dataset. Why is this??

any answers appreciated, as to due to the underlying structure of the
datasets, i.e lots of child tables etc, I cannot use bindingcontext
 
Back
Top