473,411 Members | 1,899 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

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

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
6 3296
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Amadelle | last post by:
Hi all and thanks in advance for your help, I have a problem with capturing the changed value of a text box in a datagrid. The datagrid is populated based on a dataset and I am using template...
13
by: Paul Slavin | last post by:
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...
2
by: Alpha | last post by:
Hi, I have a window based program. One of the form has several textboxes and a datagrid. The textboxes are bind to the same dataset table as the datagrid and the text changes to reflect different...
2
by: Manish | last post by:
Hey folks I am having a weird problem in ASP .Net. My page is in C#. I have a datagrid, which populates based on selection in drop down box on ASP page. This datagrid has template textbox colum in...
1
by: Amadelle | last post by:
Hi all and thanks in advance for your help, I have a problem with capturing the changed value of a text box in a datagrid. The datagrid is populated based on a dataset and I am using template...
16
by: Adda | last post by:
If I cycle through the MdiChildActivate event of the parent form I can read text in a textbox on the child mdiform -- console.writeline(Me.ActiveMdiChild.Controls(1).Text) But if I have a sub...
2
by: jose.mendez22 | last post by:
In my code I create a sqlDataAdapter that which contains a simple select command using the Northwind DB (SELECT top 15 customerID, companyName, contactName, contactTitle From Customers). I...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.