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

Textbox bind to datagrid but text doesn't change when selection ch

P: n/a
I have several textboxes that I need to chang the text when the selection row
is changed in a datagrid. I have the following code. This textbox displayes
the initial selection but when I click on different rows in the datagrid, the
textbox content doesn't change to reflect the change. How can I address
this?

Also, If the user change the text in the textbox then how do I refesh the
display in the datagrid to reflect the changes?

Thanks, Alpha
Nov 17 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Alpha,

It seems like you either have separate binding contexts, or that you are
binding to different data sources. First off, are the textboxes and data
grid in the same form? If not, then you have to create a binding context
and have the forms share it.

Second, how are you setting the data source in the bindings and the data
source in the grid? If you have a data set with a table, "Table", for
example, the following two are NOT the same:

dataGrid.DataSource = dataSet;
dataGrid.DataMember = "Table";

// Is not the same as.
dataGrid.DataSource = dataSet.Tables["Table"];

Also, are you using any views, by chance? Are you binding to different
views?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Alpha" <Al***@discussions.microsoft.com> wrote in message
news:0E**********************************@microsof t.com...
I have several textboxes that I need to chang the text when the selection
row
is changed in a datagrid. I have the following code. This textbox
displayes
the initial selection but when I click on different rows in the datagrid,
the
textbox content doesn't change to reflect the change. How can I address
this?

Also, If the user change the text in the textbox then how do I refesh the
display in the datagrid to reflect the changes?

Thanks, Alpha

Nov 17 '05 #2

P: n/a
VListing is the datagrid and it's datasource is a dataset table:
VListing.SetDataBinding(dsVehicle, "VehDetail");

The textbox is only bind to the datagrid through the same dataset table:
txtVName.DataBindings.Add("Text", dsVehicle.Tables["vehDetail"], "VName");

I don't have any view created for this. These controls are all on the same
form.

Thank you, Alpha

"Nicholas Paldino [.NET/C# MVP]" wrote:
Alpha,

It seems like you either have separate binding contexts, or that you are
binding to different data sources. First off, are the textboxes and data
grid in the same form? If not, then you have to create a binding context
and have the forms share it.

Second, how are you setting the data source in the bindings and the data
source in the grid? If you have a data set with a table, "Table", for
example, the following two are NOT the same:

dataGrid.DataSource = dataSet;
dataGrid.DataMember = "Table";

// Is not the same as.
dataGrid.DataSource = dataSet.Tables["Table"];

Also, are you using any views, by chance? Are you binding to different
views?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Alpha" <Al***@discussions.microsoft.com> wrote in message
news:0E**********************************@microsof t.com...
I have several textboxes that I need to chang the text when the selection
row
is changed in a datagrid. I have the following code. This textbox
displayes
the initial selection but when I click on different rows in the datagrid,
the
textbox content doesn't change to reflect the change. How can I address
this?

Also, If the user change the text in the textbox then how do I refesh the
display in the datagrid to reflect the changes?

Thanks, Alpha


Nov 17 '05 #3

P: n/a
Alpha,

That is the problem. You are binding to dsVehicle.Tables["vehDetail"]
in the bindings, and to the data set in the vlisting.

Change the code to set the data bindings in the VListing to:

VListing.SetDataBinding(dsVehicle.Tables["vehDetail"], null);

And it should work.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Alpha" <Al***@discussions.microsoft.com> wrote in message
news:E0**********************************@microsof t.com...
VListing is the datagrid and it's datasource is a dataset table:
VListing.SetDataBinding(dsVehicle, "VehDetail");

The textbox is only bind to the datagrid through the same dataset table:
txtVName.DataBindings.Add("Text", dsVehicle.Tables["vehDetail"], "VName");

I don't have any view created for this. These controls are all on the
same
form.

Thank you, Alpha

"Nicholas Paldino [.NET/C# MVP]" wrote:
Alpha,

It seems like you either have separate binding contexts, or that you
are
binding to different data sources. First off, are the textboxes and data
grid in the same form? If not, then you have to create a binding context
and have the forms share it.

Second, how are you setting the data source in the bindings and the
data
source in the grid? If you have a data set with a table, "Table", for
example, the following two are NOT the same:

dataGrid.DataSource = dataSet;
dataGrid.DataMember = "Table";

// Is not the same as.
dataGrid.DataSource = dataSet.Tables["Table"];

Also, are you using any views, by chance? Are you binding to
different
views?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Alpha" <Al***@discussions.microsoft.com> wrote in message
news:0E**********************************@microsof t.com...
>I have several textboxes that I need to chang the text when the
>selection
>row
> is changed in a datagrid. I have the following code. This textbox
> displayes
> the initial selection but when I click on different rows in the
> datagrid,
> the
> textbox content doesn't change to reflect the change. How can I
> address
> this?
>
> Also, If the user change the text in the textbox then how do I refesh
> the
> display in the datagrid to reflect the changes?
>
> Thanks, Alpha


Nov 17 '05 #4

P: n/a
Hummmm, like magic, it's working just great! I don't quite understand. I
followed the databinding sytax for the datagrid, to put datasource as dataset
and the datamember as the table. You have it all specified in the
datasource.

So I guess the textbox binding only looks at the datagrid's datasource and
not the datamember, is that correct? And that's the source of my problem?
Hummmm.... Thank you so much. I wouldn't have been able to figure that one
out myslef for sure.

"Nicholas Paldino [.NET/C# MVP]" wrote:
Alpha,

That is the problem. You are binding to dsVehicle.Tables["vehDetail"]
in the bindings, and to the data set in the vlisting.

Change the code to set the data bindings in the VListing to:

VListing.SetDataBinding(dsVehicle.Tables["vehDetail"], null);

And it should work.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Alpha" <Al***@discussions.microsoft.com> wrote in message
news:E0**********************************@microsof t.com...
VListing is the datagrid and it's datasource is a dataset table:
VListing.SetDataBinding(dsVehicle, "VehDetail");

The textbox is only bind to the datagrid through the same dataset table:
txtVName.DataBindings.Add("Text", dsVehicle.Tables["vehDetail"], "VName");

I don't have any view created for this. These controls are all on the
same
form.

Thank you, Alpha

"Nicholas Paldino [.NET/C# MVP]" wrote:
Alpha,

It seems like you either have separate binding contexts, or that you
are
binding to different data sources. First off, are the textboxes and data
grid in the same form? If not, then you have to create a binding context
and have the forms share it.

Second, how are you setting the data source in the bindings and the
data
source in the grid? If you have a data set with a table, "Table", for
example, the following two are NOT the same:

dataGrid.DataSource = dataSet;
dataGrid.DataMember = "Table";

// Is not the same as.
dataGrid.DataSource = dataSet.Tables["Table"];

Also, are you using any views, by chance? Are you binding to
different
views?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Alpha" <Al***@discussions.microsoft.com> wrote in message
news:0E**********************************@microsof t.com...
>I have several textboxes that I need to chang the text when the
>selection
>row
> is changed in a datagrid. I have the following code. This textbox
> displayes
> the initial selection but when I click on different rows in the
> datagrid,
> the
> textbox content doesn't change to reflect the change. How can I
> address
> this?
>
> Also, If the user change the text in the textbox then how do I refesh
> the
> display in the datagrid to reflect the changes?
>
> Thanks, Alpha


Nov 17 '05 #5

P: n/a
Alpha,

It does look at both the data source and the data member, but it uses
those two things together to determine if the data source is the same.
Since the data source for one was the table, and the data source for the
other was the data set (while the data member was null and the name of the
table respectively), it considers the data sources separate.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Alpha" <Al***@discussions.microsoft.com> wrote in message
news:5D**********************************@microsof t.com...
Hummmm, like magic, it's working just great! I don't quite understand. I
followed the databinding sytax for the datagrid, to put datasource as
dataset
and the datamember as the table. You have it all specified in the
datasource.

So I guess the textbox binding only looks at the datagrid's datasource and
not the datamember, is that correct? And that's the source of my problem?
Hummmm.... Thank you so much. I wouldn't have been able to figure that
one
out myslef for sure.

"Nicholas Paldino [.NET/C# MVP]" wrote:
Alpha,

That is the problem. You are binding to
dsVehicle.Tables["vehDetail"]
in the bindings, and to the data set in the vlisting.

Change the code to set the data bindings in the VListing to:

VListing.SetDataBinding(dsVehicle.Tables["vehDetail"], null);

And it should work.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Alpha" <Al***@discussions.microsoft.com> wrote in message
news:E0**********************************@microsof t.com...
> VListing is the datagrid and it's datasource is a dataset table:
> VListing.SetDataBinding(dsVehicle, "VehDetail");
>
> The textbox is only bind to the datagrid through the same dataset
> table:
> txtVName.DataBindings.Add("Text", dsVehicle.Tables["vehDetail"],
> "VName");
>
> I don't have any view created for this. These controls are all on the
> same
> form.
>
> Thank you, Alpha
>
> "Nicholas Paldino [.NET/C# MVP]" wrote:
>
>> Alpha,
>>
>> It seems like you either have separate binding contexts, or that
>> you
>> are
>> binding to different data sources. First off, are the textboxes and
>> data
>> grid in the same form? If not, then you have to create a binding
>> context
>> and have the forms share it.
>>
>> Second, how are you setting the data source in the bindings and
>> the
>> data
>> source in the grid? If you have a data set with a table, "Table", for
>> example, the following two are NOT the same:
>>
>> dataGrid.DataSource = dataSet;
>> dataGrid.DataMember = "Table";
>>
>> // Is not the same as.
>> dataGrid.DataSource = dataSet.Tables["Table"];
>>
>> Also, are you using any views, by chance? Are you binding to
>> different
>> views?
>>
>>
>> --
>> - Nicholas Paldino [.NET/C# MVP]
>> - mv*@spam.guard.caspershouse.com
>>
>> "Alpha" <Al***@discussions.microsoft.com> wrote in message
>> news:0E**********************************@microsof t.com...
>> >I have several textboxes that I need to chang the text when the
>> >selection
>> >row
>> > is changed in a datagrid. I have the following code. This textbox
>> > displayes
>> > the initial selection but when I click on different rows in the
>> > datagrid,
>> > the
>> > textbox content doesn't change to reflect the change. How can I
>> > address
>> > this?
>> >
>> > Also, If the user change the text in the textbox then how do I
>> > refesh
>> > the
>> > display in the datagrid to reflect the changes?
>> >
>> > Thanks, Alpha
>>
>>
>>


Nov 17 '05 #6

P: n/a
Thank you.

"Nicholas Paldino [.NET/C# MVP]" wrote:
Alpha,

It does look at both the data source and the data member, but it uses
those two things together to determine if the data source is the same.
Since the data source for one was the table, and the data source for the
other was the data set (while the data member was null and the name of the
table respectively), it considers the data sources separate.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Alpha" <Al***@discussions.microsoft.com> wrote in message
news:5D**********************************@microsof t.com...
Hummmm, like magic, it's working just great! I don't quite understand. I
followed the databinding sytax for the datagrid, to put datasource as
dataset
and the datamember as the table. You have it all specified in the
datasource.

So I guess the textbox binding only looks at the datagrid's datasource and
not the datamember, is that correct? And that's the source of my problem?
Hummmm.... Thank you so much. I wouldn't have been able to figure that
one
out myslef for sure.

"Nicholas Paldino [.NET/C# MVP]" wrote:
Alpha,

That is the problem. You are binding to
dsVehicle.Tables["vehDetail"]
in the bindings, and to the data set in the vlisting.

Change the code to set the data bindings in the VListing to:

VListing.SetDataBinding(dsVehicle.Tables["vehDetail"], null);

And it should work.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Alpha" <Al***@discussions.microsoft.com> wrote in message
news:E0**********************************@microsof t.com...
> VListing is the datagrid and it's datasource is a dataset table:
> VListing.SetDataBinding(dsVehicle, "VehDetail");
>
> The textbox is only bind to the datagrid through the same dataset
> table:
> txtVName.DataBindings.Add("Text", dsVehicle.Tables["vehDetail"],
> "VName");
>
> I don't have any view created for this. These controls are all on the
> same
> form.
>
> Thank you, Alpha
>
> "Nicholas Paldino [.NET/C# MVP]" wrote:
>
>> Alpha,
>>
>> It seems like you either have separate binding contexts, or that
>> you
>> are
>> binding to different data sources. First off, are the textboxes and
>> data
>> grid in the same form? If not, then you have to create a binding
>> context
>> and have the forms share it.
>>
>> Second, how are you setting the data source in the bindings and
>> the
>> data
>> source in the grid? If you have a data set with a table, "Table", for
>> example, the following two are NOT the same:
>>
>> dataGrid.DataSource = dataSet;
>> dataGrid.DataMember = "Table";
>>
>> // Is not the same as.
>> dataGrid.DataSource = dataSet.Tables["Table"];
>>
>> Also, are you using any views, by chance? Are you binding to
>> different
>> views?
>>
>>
>> --
>> - Nicholas Paldino [.NET/C# MVP]
>> - mv*@spam.guard.caspershouse.com
>>
>> "Alpha" <Al***@discussions.microsoft.com> wrote in message
>> news:0E**********************************@microsof t.com...
>> >I have several textboxes that I need to chang the text when the
>> >selection
>> >row
>> > is changed in a datagrid. I have the following code. This textbox
>> > displayes
>> > the initial selection but when I click on different rows in the
>> > datagrid,
>> > the
>> > textbox content doesn't change to reflect the change. How can I
>> > address
>> > this?
>> >
>> > Also, If the user change the text in the textbox then how do I
>> > refesh
>> > the
>> > display in the datagrid to reflect the changes?
>> >
>> > Thanks, Alpha
>>
>>
>>


Nov 17 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.